clean-before-html-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

clean-before-html-webpack-plugin

在html-webpack-plugin处理前,清理html里一些不必要的内容,如dev-server时引入的脚本

Usage

// webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanBeforeHtmlWebpackPlugin = require('clean-before-html-webpack-plugin');

const isProd = process.env.NODE_ENV == 'production';

module.exports = {
  plugins: [
    new HtmlWebpackPlugin({
      template: './demo/index.html',
      filename: '[name].html',
      inject: 'body'
    })
  ].concat(isProd ? [
    new CleanBeforeHtmlWebpackPlugin({
      patterns: [{
        match: '<script src="../dist/demo/index.js"></script>',
        replacement: ''
      }]
    }),
  ]: []),
};

Package Sidebar

Install

npm i clean-before-html-webpack-plugin

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

6.93 kB

Total Files

6

Last publish

Collaborators

  • lamo