Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when running webpack dev server with clean plugin clearing dist folder and content not served #96

Closed
saibhargavag opened this issue Dec 20, 2018 · 7 comments

Comments

@saibhargavag
Copy link

hi I am running webpack dev server with clean webpack plug in. It is working fine if we are just building it. but when I start dev server this plugin is clearing dist folder and so there is nothing to serve for the server and my screen is empty.

This is wepack configuratio I used.

plugins: [
new cleanWebPackOutPut(['dist/.']),
new HtmlWebpackPlugin
({
template: './src/index.html',
filename: 'index.html',
hash:true,
inject: true
})
],
devServer: {
index: 'index.html',
contentBase: path.join(__dirname, 'dist'),
compress: true,
hot: true, //Hot module replacement
port: 9000,
open: 'chrome' //open in chrome
}

@saibhargavag
Copy link
Author

hi I figured it out. webpack dev server causing the recompile and thus invocation of clean webpack plugin, which clears dist folder. but to keep files there in dist folder you must instruct it to write to disk. then after every recompile it writes files to disk this can be set through writeToDisk:true,

devServer: {
index: 'index.html',
contentBase: path.join(__dirname, 'dist'),
compress: true,
hot: true, //Hot module replacement
port: 9000,
writeToDisk:true,
open: 'chrome' //open in chrome
}

this solved my question of keeping output files generated intact.

@wenxuehai
Copy link

What version of the webpack-dev-server do you use. I have tried, but failed

@wenxuehai
Copy link

@saibhargavag

@NageshKuruva
Copy link

thanks it worked for me :)

@pabloskubert
Copy link

Oh, thank so much

@ousmanediallo95
Copy link

ousmanediallo95 commented Dec 29, 2020

Thank you dear. it worked for me .

@StepanovMax
Copy link

hi I figured it out. webpack dev server causing the recompile and thus invocation of clean webpack plugin, which clears dist folder. but to keep files there in dist folder you must instruct it to write to disk. then after every recompile it writes files to disk this can be set through writeToDisk:true,

devServer: {
index: 'index.html',
contentBase: path.join(__dirname, 'dist'),
compress: true,
hot: true, //Hot module replacement
port: 9000,
writeToDisk:true,
open: 'chrome' //open in chrome
}

this solved my question of keeping output files generated intact.

That's worked for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants