Skip to content

webpack-dev-server causes packs it serves from memory to "not be found" after killing the server and reloading the page #804

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

Closed
cjstewart88 opened this issue Sep 14, 2017 · 3 comments

Comments

@cjstewart88
Copy link

cjstewart88 commented Sep 14, 2017

Problem

I noticed after killing ./bin/webpack-dev-server and refreshing your browser the packs it's generating were no longer findable. This is due to the fact that the webpack dev server serves the files from memory and never writes to disk.

This modified bundle is served from memory at the relative path specified in publicPath (see API). It will not be written to your configured output directory. Where a bundle already exists at the same URL path, the bundle in memory takes precedence (by default).

via: https://webpack.github.io/docs/webpack-dev-server.html

Solution

I found an old issue(webpack/webpack-dev-server#62) that lead me to a plugin(https://github.com/gajus/write-file-webpack-plugin) that writes the packs to disk which will allow them to be served after the webpack-dev-servers killed.

My Confusion and Question

I'm kind of surprised the gem doesn't recognize the packs haven't actually been generated and attempt to generate them whenever its auto-compiling if the webpack-dev-server isn't running. Is there something I'm missing? Using the plugin I mentioned above works, but seems undocumented here.

@gauravtiwari
Copy link
Member

@cjstewart88 You could use watcher ./bin/webpack --watch --progress --colors that will write to file system and turn off the on demand compilation if using watcher from config/webpacker.yml (compile: false). Webpack dev server is meant to serve from memory.

@cjstewart88
Copy link
Author

@gauravtiwari thanks for the help, that'll do the trick!

@getabetterpic
Copy link
Contributor

I'm having the same problem. I've created a repo to reproduce the issue here. Steps to reproduce are in the README. The problem is if I run ./bin/webpack-dev-server everything's fine, but then if I stop using the dev server, the packs are no longer served correctly behind the scenes. A manifest gets written with a pack to serve but the pack itself doesn't get generated. Running ./bin/webpack-dev-server again fixes the issue, but would like the option to use or not use the dev server depending on my workflow at the time.

Also rm -rf public/packs fixes this issue temporarily. If I run the dev server again and quit it after doing this, then the problem resurfaces.

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

3 participants