Skip to content

plugin clean folder even on re-build #55

Closed
@shlomisas

Description

@shlomisas

I have this config:

new CleanWebpackPlugin(['dist'], {
    root: projectRoot,
    watch: false
})

But when the watcher run it deletes the folder and start the whole Webpack's build from scratch.
I know the watch flag is false by default, I added that to make sure it's settled.

I'm using Webpack version 1 due to some IE backward compatibilities, maybe this is the issue?

Thanks.

Activity

Jonathancollinet

Jonathancollinet commented on May 30, 2017

@Jonathancollinet

look at this

Paths (Required)

An [array] of string paths to clean

[
  'dist',         // removes 'dist' folder
  'build/*.*',    // removes all files in 'build' folder
  'web/*.js'      // removes all JavaScript files in 'web' folder
]
shlomisas

shlomisas commented on May 30, 2017

@shlomisas
Author

as you can see in my code sample, i already have ['dist'] array as paths to clean, but it still deletes it everytime the watcher build instead of just on the first web pack build.

ianseverance

ianseverance commented on Nov 4, 2017

@ianseverance

@shlomisas As originally mentioned by @Jonathancollinet and stated in the documentation:

By passing dist as the path, you are asking for the dist folder itself to be cleaned (removed). To remove all of the files within the dist folder, your config should actually be

new CleanWebpackPlugin([
   'dist/*.*'          // Removes all files in `dist` folder
],
{
    root: projectRoot,
    watch: false       // You can delete this, as this does not change anything for your use case
})

and if your dist folder has multiple levels, make sure to include those paths as well

new CleanWebpackPlugin([
   'dist/*.*'          // Removes all files in `dist` folder
   'dist/**/*.*'       // Removes all files in `dist/**` folders
   'dist/**/**/*.*'    // Removes all files in `dist/**/**` folders
],
{
    root: projectRoot,
    watch: false       // You can delete this, as this does not change anything for your use case
})
chrisblossom

chrisblossom commented on Mar 4, 2019

@chrisblossom
Collaborator

Closed in v2.0.0 via #99. See johnagan/clean-webpack-plugin#usage. Please open a new issue if you continue to have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @shlomisas@chrisblossom@Jonathancollinet@ianseverance

        Issue actions

          plugin clean folder even on re-build · Issue #55 · johnagan/clean-webpack-plugin