1.3.1 • Published 7 years ago
webpack-glob-clean v1.3.1
Webpack Glob Clean
A webpack plugin to clean specified files after build
Getting started
Install the plugin:
npm install webpack-glob-clean --save-dev
yarn add webpack-glob-clean --devAPI
new WebpackCleanPlugin(files: array|string, [ { [basePath: string], [removeMaps: boolean] } ])files- array of files or string for a single file relative to thebasePathor to thecontextof your config (if thebasePathparam is not specified),basePath(optional) - string - directory to be resolved toverbose(optional) - boolean - enable verbose logging. Disabled by default.forceDelete(optional) - boolean - specify if the files should be force deleted in case of compile errors. IfforceDeleteis not enabled, the compile errors will be logged tostdoutbut the deletion of the files will not take place. Disabled by default.
Usage
var WebpackCleanPlugin = require('webpack-glob-clean');
module.exports = {
context: path.join(__dirname, './'),
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new WebpackCleanPlugin([
'dist/test1.js',
'dist/test2.js'
])
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin(
'dist/fileA.js',
{basePath: path.join(__dirname, './')}
)
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin(
'dist/**/fileA.js',
{basePath: path.join(__dirname, './')}
)
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'folder/**/*.map',
'dist/*.js'
], {basePath: path.join(__dirname, 'dist')})
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'fileB.js'
], {basePath: path.join(__dirname, 'dist'), verbose: true})
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'fileB.js'
], {basePath: path.join(__dirname, 'dist'), forceDelete: true})
]
};