babel-plugin-transform-assets
Transforms importing of asset files at compile time using Babel
Last updated 2 years ago by jmurzy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-transform-assets 
SYNC missed versions from official npm registry.

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:hash:base64:7]",
              }]]
}

Via Node API

require('babel-core').transform('code', {
  plugins: [['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.

Related Projects

babel-plugin-css-modules-transform

Current Tags

  • 1.0.2                                ...           latest (2 years ago)

3 Versions

  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 0.2.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 8
Dependencies (1)
Dev Dependencies (16)

Copyright 2014 - 2016 © taobao.org |