1.0.5 • Published 1 year ago

conditional-webpack-plugin v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Conditional-Webpack-Plugin

A webpack plugin that could exclude the compiled content conditionally. That's very useful if you intent to compile you project with some different modules by run specify npm script. Note that this plugin is valid for fowllowing types of file: htmlnot template of Html-Webpack-Plugin, js, ts, jsx, tsx, vue, css, scss, sass, less

install

npm install conditional-webpack-plugin -D
yarn add conditional-webpack-plugin -D

Usage

// webpack.config.js

const ConditionalWebpackPlugin = require("conditional-webpack-plugin")

module.exports = {
	// other configurations...
	plugins: [new ConditionalWebpackPlugin()],
};

There are two ways to exclude the content you don't want: if true: statement and if def: variable, and both of them need to use endif to mark the end:

console.log("I will be shown")

// if true: true && 10 < 1
console.log("I will not be shown")
// endif

// if def: VARIABLE_NOT_EXIST
consle.log("I will not be shown either")
// endif

No matter which way you will pick, the process.env will be added at the beginning of the scope. That is to say, VARIABLE will be attempted to be interpreted as process.env.VARIABLE.

Also, you maybe have noticed that if def: VARIABLE is the abbreviation form of if true: VARIABLE !== undefined

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago