laravel-webpack-cleanup-plugin
v0.1.0
Published
Webpack plugin for clearing a destination folder keeping files listed in a manifest
Downloads
61
Maintainers
Readme
laravel-webpack-cleanup-plugin
This webpack plugin cleans up the extraneous files from the webpack's output path.
Since it runs when the compile process is finished, it is useful when building on production to remove the assets created by previous builds.
npm i -SD laravel-webpack-cleanup-plugin
⚠️ Beware! This plugins actually delete files. Make sure it's safe for your app
to delete files not generated by webpack. Use the exclude
option if you want to
keep files that are not webpack assets.
Usage
Install via npm:
npm i -SD laravel-webpack-cleanup-plugin
Then add the plugin to the plugins
array in your webpack's config, e.g.:
// webpack.config.js
import LaravelWebpackCleanupPlugin from 'laravel-webpack-cleanup-plugin';
const config = {
output: {
path: "/my/output/path" // absolute path
},
// ...
plugins: [
new LaravelWebpackCleanupPlugin('build/assets/js')
]
}
export default config;
Options
- Specify the manifest.json file.
// Default manifest file "assets/build/rev-manifest.json"
new LaravelWebpackCleanupPlugin('build/assets/js', {
manifest: 'assets/build/rev-manifest.json',
})
- If you want to keep some files in the output path, e.g. a
stats.json
file generated from some other plugins.
// Do not delete `stats.json`, `important.json`, and everything in `folder`
new LaravelWebpackCleanupPlugin('build/assets/js', {
exclude: ["stats.json", "important.js"],
})
- To mute the console output, use the
quiet
option:
new LaravelWebpackCleanupPlugin('build/assets/js', {
quiet: true,
})
- To print the list of the files that will be deleted without actually deleting them, use the
preview
option:
new LaravelWebpackCleanupPlugin('build/assets/js', {
preview: true,
})