Registry / devops / babel-plugin-transform-assets

babel-plugin-transform-assets

JSON →
library1.0.2jsnpmunverified

A Babel plugin (v1.0.2, stable) that compiles asset imports (e.g., .txt, .svg) at compile time, replacing them with hashed filenames. Eliminates the need for Webpack in universal server-side code, providing a lightweight alternative to file-loader/url-loader. Works with Babel 6+. Last updated in 2017; not actively maintained.

npm install babel-plugin-transform-assets
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-assets
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default plugin
import plugin from 'babel-plugin-transform-assets'
const plugin = require('babel-plugin-transform-assets').default
The plugin is a default export; use default import in ESM.
Babel config object
plugins: [['babel-plugin-transform-assets', { extensions: ['svg'], name: '[name].[ext]?[hash]' }]]
plugins: ['babel-plugin-transform-assets']
Plugin typically requires options; omitting options may cause unexpected behavior.

Configures the plugin with file extensions and hashing pattern; shows the transformation of an SVG import.

// .babelrc { "plugins": [ ["babel-plugin-transform-assets", { "extensions": ["svg", "png", "jpg"], "name": "[name].[ext]?[sha512:hash:base64:7]" }] ] } // Input: import file from './file.svg'; // Output: var file = 'file.svg?abc1234';
Debug
Known issues
deprecatedThe package is no longer actively maintained; last update 2017.
fix
Consider using babel-plugin-assets or inline assets via Webpack/Metro bundler for modern projects.
affects: >=1.0.0
breakingPlugin only works with Babel 6; not compatible with Babel 7+.
fix
Use Babel 6 or fork/update the plugin for Babel 7 compatibility.
affects: 1.0.0 - 1.0.2
gotchaThe plugin transforms import/require statements at compile time, so dynamic imports (e.g., import()) are not supported.
fix
Use static import statements only; for dynamic assets, consider Webpack's file-loader.
affects: >=1.0.0
Errors
Common errors & fixes
The plugin was not found. Check the plugins option.
Missing or incorrect plugin name in Babel config.
fix
Ensure 'babel-plugin-transform-assets' is installed and listed in plugins array.
Cannot find module 'babel-plugin-transform-assets'
Plugin not installed or node_modules missing.
fix
Run: npm install babel-plugin-transform-assets
SyntaxError: Unexpected token (1:20) when importing a file
Plugin not configured to handle that file extension.
fix
Add the extension to the 'extensions' array in plugin options.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
babel-plugin-transform-assets — npm install babel-plugin-transform-assets · libregistry