Socket
Socket
Sign inDemoInstall

clean-webpack-plugin

Package Overview
Dependencies
12
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building


Version published
Weekly downloads
1.5M
decreased by-18.45%
Maintainers
1
Install size
172 kB
Created
Weekly downloads
 

Package description

What is clean-webpack-plugin?

The clean-webpack-plugin is a plugin for webpack, a module bundler for JavaScript. It is used to remove/clean your build folder(s) before building. This ensures that only used files are generated when your project is built, preventing the accumulation of outdated files from previous builds.

What are clean-webpack-plugin's main functionalities?

Removing all files inside webpack's output.path directory

This feature automatically cleans up the output directory specified in webpack's configuration before each build, ensuring that only the files generated in the current build are present.

const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
  plugins: [
    new CleanWebpackPlugin(),
  ],
};

Preserving specific files or directories during clean

This feature allows you to exclude specific files or directories from being deleted when the output directory is cleaned. This is useful for cases where you want to keep certain files across builds.

const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
  plugins: [
    new CleanWebpackPlugin({
      cleanOnceBeforeBuildPatterns: ['**/*', '!static-files*'],
      cleanStaleWebpackAssets: false,
      protectWebpackAssets: false
    }),
  ],
};

Other packages similar to clean-webpack-plugin

Readme

Source

Clean for webpack

A webpack plugin to remove/clean your build folder(s) before building

Build Status Coveralls Status

Installation

npm install clean-webpack-plugin --save-dev

Example Webpack Config

var CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
  plugins: [
    new CleanWebpackPlugin(['dist', 'build'], {
      root: '/full/project/path',
      verbose: true, 
      dry: false
    })
  ]
}

Usage

new CleanWebpackPlugin(paths [, {options}])

Paths (Required)

An [array] of string paths to clean

['dist', 'build']

Options and defaults (Optional)

{
  "root": "[location of webpack.config]", // An absolute path for the root.
  "verbose": true, // Write logs to console.
  "dry": false, // Do not delete anything, good for testing.
}

License

http://www.opensource.org/licenses/mit-license.php

Keywords

FAQs

Last updated on 27 Apr 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc