https://github.com/jsdf/only-if-changed-webpack-plugin
Webpack plugin to only run build if dependent files have changed
https://github.com/jsdf/only-if-changed-webpack-plugin
Last synced: over 1 year ago
JSON representation
Webpack plugin to only run build if dependent files have changed
- Host: GitHub
- URL: https://github.com/jsdf/only-if-changed-webpack-plugin
- Owner: jsdf
- License: isc
- Created: 2016-04-07T03:55:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T21:43:17.000Z (over 3 years ago)
- Last Synced: 2025-03-14T20:55:42.453Z (over 1 year ago)
- Language: JavaScript
- Size: 595 KB
- Stars: 18
- Watchers: 4
- Forks: 13
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# only-if-changed-webpack-plugin
Webpack plugin to only run build if dependent files have changed
## Example
```js
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](https://github.com/jsdf/cached-loader) – Adds persistent on-disk caching to webpack loaders