1.0.0 • Published 5 years ago

webpack-strip-function v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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