npm.io
1.0.6 • Published 6 years ago

html-webpack-replace-assets-plugin

Licence
ISC
Version
1.0.6
Deps
1
Size
8 kB
Vulns
0
Weekly
0

html-webpack-replace-assets-plugin

Build Status npm package npm downloads

A plugin to help webpack concat js and inject into html

Why

Webpack is really powerful. However, when I want to change the asset files and inject into html without webpack JSONP code wrapper, it seems impossible to do that without other tool's help.

Install

npm install html-webpack-replace-assets-plugin --save-dev
Features
  • replace assets path when inject to html(with html-webpack-plugin)
Usage
const HtmlWebpackReplaceAssetsPlugin = require('html-webpack-replace-assets-plugin');

new HtmlWebpackReplaceAssetsPlugin({
  ...see options
  // examples
  convert(asset, path) {
    // asset: webpack asset object
    // path: asset path
    return path.replace('.js', `${asset.size()}.js.gz`);
  }
});
Options
convert [Function] default: (asset, path) => name

assets path(or name) transformer

TODO
  • add css support