JSPM

babel-plugin-transform-assets

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 943
  • Score
    100M100P100Q111219F
  • License MIT

Transforms importing of asset files at compile time using Babel

Package Exports

  • babel-plugin-transform-assets

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-transform-assets) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-plugin-transform-assets

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.

CircleCI npm version npm

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 babel-plugin-transform-assets

Usage

Via .babelrc

.babelrc

{
  "plugins": [["transform-assets", {
                "extensions": ["svg"],
                "name": "[name].[ext]?[sha512#️⃣base64:7]",
              }]]
}

Via Node API

require('babel-core').transform('code', {
  plugins: [['transform-assets', {
              extensions: ['svg'],
              name: '[name].[ext]?[sha512#️⃣base64:7]',
            }]]
});

Contributing

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

babel-plugin-css-modules-transform