• Version 4.0.0
  • Published
  • 35.7 kB
  • 1 dependency
  • MIT license


npm i clean-webpack-plugin
yarn add clean-webpack-plugin
pnpm add clean-webpack-plugin


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



class CleanWebpackPlugin

class CleanWebpackPlugin {}


    constructor(options?: Options);

      method apply

      apply: (compiler: Compiler) => void;

        method handleDone

        handleDone: (stats: Stats) => void;

          method handleInitial

          handleInitial: (compilation: Compilation) => void;
          • Initially remove files from output directory prior to build.

            Only happens once.

            Warning: It is recommended to initially clean your build directory outside of webpack to minimize unexpected behavior.

          method removeFiles

          removeFiles: (patterns: string[]) => void;


            interface Options

            interface Options {}

              property cleanAfterEveryBuildPatterns

              cleanAfterEveryBuildPatterns?: string[];
              • Removes files after every build (including watch mode) that match this pattern. Used for files that are not created directly by Webpack.

                Use !negative patterns to exclude files

                default: []

              property cleanOnceBeforeBuildPatterns

              cleanOnceBeforeBuildPatterns?: string[];
              • Removes files once prior to Webpack compilation Not included in rebuilds (watch mode)

                Use !negative patterns to exclude files

                default: ['**/*']

              property cleanStaleWebpackAssets

              cleanStaleWebpackAssets?: boolean;
              • Automatically remove all unused webpack assets on rebuild

                default: true

              property dangerouslyAllowCleanPatternsOutsideProject

              dangerouslyAllowCleanPatternsOutsideProject?: boolean;
              • Allow clean patterns outside of process.cwd()

                requires dry option to be explicitly set

                default: false

              property dry

              dry?: boolean;
              • Simulate the removal of files

                default: false

              property protectWebpackAssets

              protectWebpackAssets?: boolean;
              • Do not allow removal of current webpack assets

                default: true

              property verbose

              verbose?: boolean;
              • Write Logs to Console (Always enabled when dry is true)

                default: false

              Package Files (1)

              Dependencies (1)

              Dev Dependencies (25)

              Peer Dependencies (1)


              To add a badge like this badgeto your package's README, use the codes available below.

              You may also use to create a custom badge linking to

              • Markdown
              • HTML
                <a href=""><img src="" alt=""></a>