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

docs(development): Add warning about dev server #2459

Merged
merged 3 commits into from
Sep 2, 2018

Conversation

GAumala
Copy link
Contributor

@GAumala GAumala commented Aug 22, 2018

In the Development guide, add a warning about the dev server not writing any output files.

I was recently using webpack for a new project, and had a little trouble setting up the dev server because of some misunderstandings about how it works. If the dev server says that it compiles files, I'd expect an output to be written somewhere, just like when you run webpack from the terminal.

However this is not the case and it left me puzzled for a while. It seems a lot of people also find this not so obvious so I decided to try help a little with this PR. Let me know what you think.

@montogeek
Copy link
Member

montogeek commented Aug 22, 2018

I am not entirely sure this should be added:
https://github.com/webpack/webpack-dev-server says in the 3rd line:

It uses webpack-dev-middleware under the hood, which provides fast in-memory access to the webpack assets.

https://github.com/webpack/webpack-dev-middleware first item is:

No files are written to disk, rather it handles files in memory

Also, that section already have a documentation link:

The webpack-dev-server comes with many configurable options. Head over to the documentation to learn more.

That link should point to https://github.com/webpack/webpack-dev-server though.

Maybe updating that link would be enough?

@EugeneHlushko
Copy link
Member

On one hand the readme has it, on the other hand adding a note block wont hurt at least and maybe even helps % of readers. lets see what @jeremenichelli can say this is a 50/50 for me

@GAumala
Copy link
Contributor Author

GAumala commented Aug 22, 2018

Hello guys, thanks for the quick responses. My main issue is that the development guide, gives the illusion that Watch Mode, the dev server, and the dev middleware are three options that achieve the same thing and you can seamlessly switch between them.

My experience was like this. I first setup Watch Mode and it was a breeze. Everytime I made a change to my source files, a new bundle was written to the output directory. Everything just worked. But a bit later, I noticed the inconvenience of having to manually reload all the time, plus I needed to proxy some requests to my API, so I definitely needed some kind of server. So I read the guide, right after explaining Watch Mode, it goes on about the dev server. I think "this is just what I need" and read that block and update my config. But now my output directory isn't being updated and I'm confused trying to figure out what I did wrong. I did read the dev server's README, but "fast in-memory acess" does not imply that there won't be any output files written. It just means "this is super fast".

Certainly, the dev middleware's README is the only one that explains this. But If I'm having trouble setting up the dev server I wouldn't think about reading that README unless I decide to ditch the dev server and roll out my own with the dev middleware. Besides, wouldn't you agree that having to read about the dev middleware in order to understand how the dev server works can be considered a leaky abstraction?

@jeremenichelli
Copy link
Member

I agree with adding it, the sooner a person finds out about a strange behavior the beetter for dev adoption. I would short it down a little bit though, like:

webpack-dev-server doesn't write any output files. Instead, it keeps bundle files in memory and serves them as if they were real files mounted at the server's root path. If your page expects to find the bundle files in different path, you can change this by using publicPath option in the dev server's configuration.

@GAumala GAumala force-pushed the dev-server-output branch 2 times, most recently from 127fabf to c9c51e4 Compare August 23, 2018 22:58
@GAumala
Copy link
Contributor Author

GAumala commented Aug 23, 2018

Sounds good, I updated my changes.

@@ -205,6 +206,8 @@ __webpack.config.js__

This tells `webpack-dev-server` to serve the files from the `dist` directory on `localhost:8080`.

W> webpack-dev-server doesn't write any output files after compiling. Instead, it keeps bundle files in memory and serves them as if they were real files mounted at the server's root path. If your page expects to find the bundle files in different path, you can change this with the [`publicPath`](../../configuration/dev-server/#devserver-publicpath-) option in the dev server's configuration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use absolute links: /configuration/dev-server/#devserver-publicpath-

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! :)

@GAumala GAumala force-pushed the dev-server-output branch from c9c51e4 to a0eee16 Compare August 24, 2018 01:43
In the Development guide, add a warning about the dev server not writing
any output files.
@montogeek
Copy link
Member

@jeremenichelli @EugeneHlushko Please review

Copy link
Member

@EugeneHlushko EugeneHlushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@montogeek montogeek merged commit c54bcf9 into webpack:master Sep 2, 2018
@montogeek
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants