oic

only-if-changed-webpack-plugin

Webpack plugin to only run build if dependent files have changed

Showing:

Popularity

Downloads/wk

684

Maintenance

No Maintenance Data Available

Package

Dependencies

2

Size (min+gzip)

5.8KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

only-if-changed-webpack-plugin

Webpack plugin to only run build if dependent files have changed

Example

var path = require('path')
var OnlyIfChangedPlugin = require('only-if-changed-webpack-plugin')

var opts = {
    rootDir: process.cwd(),
    devBuild: process.env.NODE_ENV !== 'production',
}

module.exports = {
    output: {
        filename: 'bundle.js',
        path: path.join(opts.rootDir, 'build'),
        pathinfo: opts.devBuild,
    },
    plugins: [
        new OnlyIfChangedPlugin({
            cacheDirectory: path.join(opts.rootDir, 'tmp/cache'),
            cacheIdentifier: opts, // all variable opts/environment should be used in cache key
        }),
    ],
}

After a successful build, all subsequent builds will skip compiling and emitting assets unless an input file dependency or output asset of the build has been modified or deleted.

See also

  • cached-loader – Adds persistent on-disk caching to webpack loaders

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100