Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cleandir-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cleandir-webpack-plugin

cleandir-webpack-plugin <a href="https://www

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cleandir-webpack-plugin

This plugin allows you to delete files/directories before or after bundle compilation.
Comparing to most popular cleanup plugin, cleandir-webpack-plugin provides you ability to run plugin after files was written to output directory and ability to exclude files with glob patterns.

Installation

npm i --save cleandir-webpack-plugin

Example

// webpack.conf.js
const CleanDirWebpackPlugin = require("cleandir-webpack-plugin");

module.exports = {
    plugins: [
        new CleanDirWebpackPlugin("dist/"), // removing whole dist dir
        new CleanDirWebpackPlugin([
                                      "dist/css/*.js",          // removing js generated by sass plugin
                                      "dist/some/directory/**", // and something else generated by build
                                  ],
                                  {
                                      stage:   "after",
                                      exclude: "dist/some/directory/**.log",    // excepting the *.log files
                                      silent:  true,
                                  },
        ),
    ],
};

Usage

// webpack.conf.js
const CleanDirWebpackPlugin = require("cleandir-webpack-plugin");

module.exports = {
    plugins:[
            new CleanDirWebpackPlugin(paths [, options])
    ]
}
paths (required)

Paths can be a valuable string or an array of strings.
Each string should be a valid glob pattern (node-glob is used under the hood).

options (optional)
const options = {
    // The momen when cleanup will be triggered, before or after emitting assets to output dir.
    // This way you will be able to remove redundant files generated by webpack
    // 
    // Variants: "before", "after"
    // Default: "before"
    stage: "before",
    
    // Same as paths parameter, but files and direcroties matching given globs wont be deleted
    //
    // Default: []
    exclude: [],
    
    // If true writes result of each glob processing
    //
    // Default: true
    verbose: true,
    
    // If true, will not generate any console output (excepting error)
    //
    // Default: false
    silent: false,
    
    // If true, will only emulate deletion (will not remove files)
    //
    // Default: false
    dryRun: false,
    
    // Allow plugin to clean paths outside of given root path
    //
    // Default: false
    allowExternal: false,
    
    // Path that will be treated as relative root for globs
    //
    // Default: path.dirname(module.parent.filename)
    root: path.dirname(module.parent.filename),
}

Tests

npm i
npm run test

Coverage

npm i
npm run test:coverage

Keywords

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc