awesome-webpack icon indicating copy to clipboard operation
awesome-webpack copied to clipboard

Add remove-files-webpack-plugin

Open Amaimersion opened this issue 4 years ago • 1 comments

remove-files-webpack-plugin is a flexible plugin that removes files and folders before and after compilation.

Features

  • removing before and after compilation ("watch" mode is supported).
  • removing in trash.
  • removing outside the root.
  • before removing folders and files are checked for safety (i.e. if removing of folder/file is unsafe, then it will be not removed).
  • emulating of remove process.
  • flexible test system.
  • customizable log system.
  • pretty output.

Examples

new RemovePlugin({
    /**
     * Before compilation permanently removes
     * entire `./dist` folder.
     */
    before: {
        include: [
            './dist'
        ]
    }
})
new RemovePlugin({
    /**
     * After compilation removes in trash
     * all maps files in `./dist/styles` folder and 
     * all subfolders (e.g. `./dist/styles/header`).
     */
    after: {
        test: [
            {
                folder: 'dist/styles',
                method: (absoluteItemPath) => {
                    return new RegExp(/\.map$/, 'm').test(absoluteItemPath);
                },
                recursive: true
            }
        ],
        trash: true
    }
})

Pretty output

remove-files-webpack-plugin

Please see source readme for detailed description and examples.

Amaimersion avatar Feb 26 '20 18:02 Amaimersion

CLA assistant check
All committers have signed the CLA.

jsf-clabot avatar Feb 26 '20 18:02 jsf-clabot