@dr.pogodin/babel-plugin-transform-assets

1.2.2 • Public • Published

Babel Plugin Transform Assets

Latest NPM Release NPM Downloads GitHub Repo stars

Transforms importing of asset files at compile time using Babel. This plugin removes the need to run your server code through Webpack module bundler when using loaders such as file-loader, url-loader and building isomorphic universal apps. Aids in creating a cleaner, maintainable build process at the cost of yet another Babel plugin.

Sponsor


This is a fork of babel-plugin-transform-assets upgraded to be compatible with the latest Webpack's file-loder, and to use the latest versions of all dependencies. For migration just prefix the plugin name with @dr.pogodin/ scopename in your package.json and Babel configs.


Example

import file from '../file.txt';

will be transformed to

var file = 'file.txt?9LDjftP';

See the spec for more examples.

Requirements

Babel v6 or higher.

Installation

npm install -D @dr.pogodin/babel-plugin-transform-assets

Usage

Via .babelrc

.babelrc

{
  "plugins": [
      ["@dr.pogodin/transform-assets", {
          "extensions": ["svg"],
          "name": "[name].[ext]?[sha512:hash:base64:7]"
      }]
  ]
}

Via Node API

require('babel-core').transform('code', {
    plugins: [
        ['@dr.pogodin/transform-assets', {
            extensions: ['svg'],
            name: '[name].[ext]?[sha512:hash:base64:7]',
        }]
    ]
});

Contributing

Contributions are very welcome—bug fixes, features, documentation, tests. Just make sure the tests are passing.

Package Sidebar

Install

npm i @dr.pogodin/babel-plugin-transform-assets

Weekly Downloads

68

Version

1.2.2

License

MIT

Unpacked Size

7.47 kB

Total Files

4

Last publish

Collaborators

  • dr.pogodin