Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
remove-files-webpack-plugin
Advanced tools
A plugin for webpack that removes files and folders before and after compilation.
A plugin for webpack that removes files and folders before and after compilation.
npm
:npm install remove-files-webpack-plugin
yarn
:yarn add remove-files-webpack-plugin
The plugin works on any OS and webpack >= 2.2.0.
const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
plugins: [
new RemovePlugin({
before: {
// parameters for "before compilation" stage.
},
after: {
// parameters for "after compilation" stage.
}
})
]
};
Name | Type | Default | Description |
---|---|---|---|
root | string | . | A root directory. Not absolute paths will be appended to this. Defaults to where package.json and node_modules are located. |
include | string[] | [] | A folders or files for removing. |
exclude | string[] | [] | A files for excluding. |
test | TestObject[] | [] | A folders for testing. |
TestObject.folder | string | Required | A path to the folder. |
TestObject.method | (filePath: string) => boolean | Required | A method that accepts file path (root + directoryPath + fileName) and returns value that indicates should be this file be removed or not. |
TestObject.recursive | boolean | false | Test in all subfolders, not just in TestObject.folder . |
trash | boolean | true | Move folders or files to trash (recycle bin) instead of permanent removing. |
log | boolean | true | Print messages of "info" level (example: "Which folders or files have been removed"). |
logWarning | boolean | true | Print messages of "warning" level (example: "An items for removing not found"). |
logError | boolean | false | Print messages of "error" level (example: "No such file or directory"). |
logDebug | boolean | false | Print messages of "debug" level (used for developers of the plugin). |
emulate | boolean | false | Emulate remove process. Print which folders or files will be removed without actually removing them. Ignores log value. |
allowRootAndOutside | boolean | false | Allow removing of root directory or outside root directory. It is kind of safe mode. Don't turn it on if you don't know what you actually do! |
You can pass these parameters into both before
and after
keys. Each key is optional, but at least one should be specified.
before
- executes before compilation;after
- executes after compilation.const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
plugins: [
new RemovePlugin({
/**
* Before compilation removes entire
* `./dist` folder to trash.
*/
before: {
include: [
'dist'
]
},
/**
* After compilation removes all files in
* `./dist/styles` folder that have `.map` extension
* to trash.
*/
after: {
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
}
]
}
})
]
};
new RemovePlugin({
/**
* Before compilation removes entire
* `./dist` folder to trash.
*/
before: {
include: [
'dist'
]
},
/**
* After compilation removes all css maps
* in `./dist/styles` folder to trash except
* `popup.css.map` file.
*/
after: {
exclude: [
'dist/styles/popup.css.map'
],
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
}
]
}
})
new RemovePlugin({
/**
* After compilation removes all css maps in
* `./dist/styles` folder to trash and all subfolders
* (e.g. `./dist/styles/header`).
*/
after: {
test: [
{
folder: 'dist/styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
},
recursive: true
}
]
}
})
new RemovePlugin({
/**
* Before compilation removes both
* `./dist/manifest.json` file and `./dist/js` folder
* to trash.
*/
before: {
root: './dist',
include: [
'manifest.json',
'js'
]
}
})
new RemovePlugin({
/**
* After compilation:
* - removes all css maps in `./dist/styles` folder to trash.
* - removes all js maps in `./dist/scripts` folder to trash and
* all subfolders (e.g. `./dist/scripts/header`).
*/
after: {
root: './dist',
test: [
{
folder: './styles',
method: (filePath) => {
return new RegExp(/\.map$/, 'm').test(filePath);
}
},
{
folder: './scripts',
method: (filePath) => {
return new RegExp(/\.js.map$/, 'm').test(filePath);
},
recursive: true
}
]
}
})
new RemovePlugin({
/**
* Before compilation permanently removes both
* `./dist/manifest.json` file and `./dist/js` folder.
* Log only works for warnings and errors.
*/
before: {
root: './dist',
include: [
'manifest.json',
'js'
],
trash: false,
log: false,
logWarning: true,
logError: true,
logDebug: false
}
})
new RemovePlugin({
/**
* Before compilation emulates remove process
* for a file that outside of the root directory.
* That file will be removed in trash.
*/
before: {
root: '.', // "D:\\remove-files-webpack-plugin-master"
include: [
"C:\\Desktop\\test.txt"
],
trash: true,
emulate: true,
allowRootAndOutside: true
}
})
Feel free to use issues. Pull requests are also always welcome!
MIT.
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 27,695 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.