johnagan / clean-webpack-plugin

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Files written to disk removed after save

coreyworrell opened this issue · comments

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
  ]
}

Please post your full configuration. Try:

new CleanWebpackPlugin({
	cleanStaleWebpackAssets: false
})

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.

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.

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.

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

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