1.4.0 • Published 4 years ago

modify-webpack-plugin v1.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

modify-webpack-plugin

a webpack plugin modify any file with new string befor webpack building
(for webpack v4)

Install

# use npm
npm install --save-dev modify-webpack-plugin
# use yarn
yarn add modify-webpack-plugin -D

Usage

// webpack.config.js
const ModifyWebpackPlugin = require("modify-webpack-plugin")

module.exports = {
  plugins: [
    new ModifyWebpackPlugin({
      include: [/\.js$/]
      exclude: ['node_modules']
      patterns: [{
        reg: /console\.log\(.*\)/g
        newStr: ''
      }]
    }),
  ]
}

This case will remove all console.log in the required *.js modules

:warning: if you don't give a argument for include, this plugin wil modify every required file even css, jpg or anyother type. So set the include !

Options

new ModifyWebpackPlugin(options: object)
NameTypeDescription
includeString\|RegExp\|Array<String\|RegExp>If multiple conditions are provided, matching any condition will include & scan the filepath to modify target files.
excludeString\|RegExp\|Array<String\|RegExp>If multiple conditions are provided, matching any condition will exclude the filepath, which prevents any alterations. By default, nothing is excluded!
patternsArray<{reg: String\|RegExp, newStr: string}>An array of RegExp pattern definitions. Each definition is an object with reg and newStr keys.
1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago