webpack-strip-function

1.0.0 • Public • Published

webpack-strip-function

Webpack plugin to strip any function call that you specified that are only intended for development purposes

Install

NPM

npm i --save-dev webpack-strip-assert

Yarn

yarn add -D webpack-strip-assert

Example

// webpack.config.js
 
const path = require("path");
 
module.exports = env => {
  return {
    entry: "./index.js",
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "index.js"
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          loader: "webpack-strip-assert",
          options: {
            funcCall: "assert"
          }
        }
      ]
    }
  };
};
// index.js
 
console.log("Hello webpack-strip-function");
 
function add(a, b) {
  return a + b;
}
assert("Add result should be 2", add(1, 1));

Then run webpack --mode production in bash, you will get bellow ☟

// dist/index.js
 
...
console.log("Hello webpack-strip-function"); // assert function call be removed!🙆 ‍

TODO

  • Support remove multip function call

LICENSE

MIT

AUTHOR

Aiello.Chan@gmail.com

Package Sidebar

Install

npm i webpack-strip-function

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.28 kB

Total Files

4

Last publish

Collaborators

  • aiellochan