1.0.5 • Published 5 months ago

conditional-webpack-plugin v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months 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

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago