johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 135 forks source link

Files written to disk removed after save #154

Closed coreyworrell closed 5 years ago

coreyworrell commented 5 years ago

When using devServer.writeToDisk: true, files are written to disk correctly, but after saving a file and Webpack compiles again, those files are not on disk anymore.

Webpack Config

{
  devServer: {
    writeToDisk: true
  },
  plugins: [
    new CleanWebpackPlugin
  ]
}
chrisblossom commented 5 years ago

Please post your full configuration. Try:

new CleanWebpackPlugin({
    cleanStaleWebpackAssets: false
})
coreyworrell commented 5 years ago

That seems to fix it. Not sure if there are any side effects, or why Webpack now thinks those assets are stale, as this seems to have only started after updating to latest versions of Webpack and plugin.

coreyworrell commented 5 years ago

I found another thread that mentioned using the cleanAfterEveryBuildPatterns, so I will use that instead since I am only concerned with it losing svg files for now. The files it was "losing" are genereated from the CopyWebpackPlugin, so maybe the root issue is on their side.

chrisblossom commented 5 years ago

I've attempted to put a PR for copy-webpack-plugin but it has stalled waiting for input.

cleanAfterEveryBuildPatterns: ['!**/*.svg'] should work great if that is all you need to ignore.

coreyworrell commented 5 years ago

Okay perfect, hopefully that gets some traction over there soon. Appreciate the help!

chrisblossom commented 5 years ago

Going to close this. Please open a new issue if you have anymore issues.