
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
remove-files-webpack-plugin
Advanced tools
A plugin for webpack which removes files and folders before and after compilation.
A plugin for webpack which removes files and folders before and after compilation.
npm install remove-files-webpack-plugin --save-dev
const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
plugins: [
new RemovePlugin({
before: {
// parameters.
},
after: {
// parameters.
}
})
]
}
Be aware! You cannot undo deletion of folders/files. Use the emulate
option if you not sure about correctness of the parameters.
Name | Type | Default | Description |
---|---|---|---|
root | String | __dirname | The root directory. A not absolute paths will appends to this. |
include | Array<String> | [] | The folders/fils for remove. |
exclude | Array<String> | [] | The files for exclude. |
test | Array<TestObject> | [] | The custom testing. |
TestObject.folder | String | Required | The folder for custom testing. |
TestObject.method | (filePath: String) => Boolean | Required | The method for custom testing. |
TestObject.recursive | Boolean | false | Test in all subfolders, not just in TestObject.folder. |
log | Boolean | true | Print which folders/files has been removed. |
emulate | Boolean | false | Emulate remove. Print which folders/files will be removed without actually removing them. Ignores log value. |
allowRootAndOutside | Boolean | false | Allow remove the root directory and outside the root directory. It's kinda safe mode. Don't turn on it if you don't know what you actually want! |
You can pass the options into both before
and after
keys. Each key is optional, but at least one should be specified.
before
- before compilation, after
- after compilation.
const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
plugins: [
new RemovePlugin({
before: {
include: ['dist']
},
after: {
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
}
]
}
})
]
}
/**
* Before compilation:
* - delete the "dist" folder.
*
* After compilation:
* - remove all css maps in the "dist/styles" folder except the "popup.css.map".
*/
new RemovePlugin({
before: {
include: ['dist']
},
after: {
exclude: ['dist/styles/popup.css.map'],
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
}
]
}
})
/**
* After compilation:
* - remove all css maps in "dist/styles" folder and all subfolders (e.g. "dist/styles/a").
*/
new RemovePlugin({
after: {
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
},
recursive: true
}
]
}
})
/**
* Before compilation:
* - remove the "manifest.json" file;
* - remove the "dist/js" folder.
*/
new RemovePlugin({
before: {
include: ['dist/manifest.json', 'dist/js']
}
})
/**
* After compilation:
* - remove all css maps in the "dist/styles" folder;
* - remove all js maps in the "dist/scripts" folder and all subfolders (e.g. "dist/styles/a").
*/
new RemovePlugin({
after: {
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
},
{
folder: 'dist/scripts',
method: (filePath) => {
return new RegExp(/\.js.map$/, 'm').test(filePath);
},
recursive: true
}
]
}
})
Feel free to use issues. Pull requests are also always welcome!
1.0.0 (June 5, 2018)
Initial release.
FAQs
A plugin for webpack that removes files and folders before and after compilation.
The npm package remove-files-webpack-plugin receives a total of 22,096 weekly downloads. As such, remove-files-webpack-plugin popularity was classified as popular.
We found that remove-files-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.