Skip to content

conradreuter/if-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

If Webpack Plugin

npm

Installation

npm install --save-dev if-webpack-plugin

or

yarn add -D if-webpack-plugin

Usage

In your Webpack configuration in the plugins section:

// webpack.config.js
const IfPlugin = require('if-webpack-plugin')
const SuperCoolPlugin = require('super-cool-webpack-plugin')
const LessCoolPlugin = require('less-cool-webpack-plugin')
module.exports = {
  // ...
  plugins: [
    new IfPlugin(
      foo === 'bar',
      new SuperCoolPlugin(),
      new LessCoolPlugin()
    )
  ]
}

The third argument can also be omitted in order to include an empty plugin, i.e. a plugin that simply does nothing:

// webpack.config.js
const IfPlugin = require('if-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
  // ...
  plugins: [
    new IfPlugin(
      process.env.NODE_ENV === 'production',
      new UglifyJsPlugin()
    )
  ]
}

About

Conditionally include Webpack plugins.

Resources

License

Stars

Watchers

Forks

Packages

No packages published