condition-compile-plugin

1.0.3 • Public • Published

condition-compile-plugin

condition compile support require module not bundle

Install

npm i condition-compile-plugin --save-dev
yarn add -D condition-compile-plugin

Usage

config

const ConditionCompilePlugin = require('condition-compile-plugin')

new webpack.DefinePlugin({
  "process.env": {
    "RUN_ENV": JSON.stringify('development')
  }
}),
new ConditionCompilePlugin(),

use

if (process.env.RUN_ENV == "development") { //true
  require("./a.js");
} else {
  require("./b.js"); //code remove and module not bundle
}

process.env.RUN_ENV == "development"/* true */ ? require("./a.js") : require("./b.js")/* code remove and module not bundle */;

Package Sidebar

Install

npm i condition-compile-plugin

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

3.52 kB

Total Files

3

Last publish

Collaborators

  • keyboard3