4.0.0 • Published 3 years ago
fs-webpack-plugin v4.0.0
Why?
Both copy-webpack-plugin
and clean-webpack-plugin
recreate existing native functionality so why not use those?
Note: clean
can be replaced with Webpack's output.clean
Usage
webpack.config.js
const FsWebpackPlugin = require('fs-webpack-plugin');
module.exports = {
plugins: [
new FsWebpackPlugin([{
// Delete folder `build` recursively
type: 'delete',
files: ['build'] // process.cwd() + build
}, {
// Delete file `build/index.test.js`
type: 'delete',
files: ['build/index.test.js'] // process.cwd() + build/index.test.js
}, {
// Delete file `build/index.test.js`,
type: 'delete',
files: ['index.test.js'],
root: path.resolve(__dirname, 'build') // Must be absolute
}, {
// Delete file `build/index.test.js` and folder `build/test`
type: 'delete',
files: [
'index.test.js',
'test'
],
root: path.resolve(__dirname, 'build')
}, {
// Copy folder `assets` recursively to `build/assets`
type: 'copy',
files: [{ from: 'assets', to: 'build' }]
}, {
// Copy file `assets/image.png` to `build/image.png`
type: 'copy',
files: [{ from: 'assets/image.png', to: 'build' }]
}])
]
}
Options
new FsWebpackPlugin(actions, options)
actions (Action[])
- Array of action objectsoptions.verbose (Boolean)
- Enable logging (defaulttrue
)options.strict (Boolean)
- Should throw errors instead of logging them (defaultfalse
)options.dry (Boolean)
- Enable dry run (defaultfalse
). Please note thatoptions.dry
will not output to console ifoptions.verbose
isfalse
Action
type (String)
- Action type, must be one ofcopy
,delete
files (String[]|{ from: String, to: String}[]
- Files or directorys to delete.copy
only accepts{ from, to }
. If paths are relative, usesroot
root (String)
- Absolute path used byfiles
, defaults toprocess.cwd()
hooks (String[])
- Webpack hooks to run action on, defaults to['beforeRun']
4.0.0
3 years ago
3.1.3
3 years ago
3.1.2
4 years ago
3.1.1
5 years ago
3.1.0
5 years ago
3.0.0
5 years ago
2.4.1
5 years ago
2.4.0
5 years ago
2.2.11
5 years ago
2.2.9
5 years ago
2.2.8
5 years ago
2.3.0
5 years ago
2.2.1
5 years ago
2.1.2
5 years ago
2.1.4
5 years ago
2.2.2
5 years ago
2.1.3
5 years ago
2.1.5
5 years ago
2.2.7
5 years ago
2.2.6
5 years ago
2.2.0
5 years ago
2.1.1
5 years ago
2.1.0
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago