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

Added Webpack Dev Server to Vanilla JS #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theajr
Copy link
Contributor

@theajr theajr commented Oct 21, 2019

Hello @jakoblind

This is to support use case mentioned in #41.

Summary of this PR:

  • Added webpack-dev-server start script to Vanilla JS projects.
  • Same script is working great for VueJS project as well.
  • Added devServer config to Vanilla JS project to serve the correct directory, earlier it was serving the project root, which is shown in below screenshot.

Screenshot 2019-10-21 at 3 23 29 PM

Please review and merge.

@theajr
Copy link
Contributor Author

theajr commented Oct 21, 2019

@jakoblind The same changes are working for Svelte project as well.
It is refreshing the browser tab on code change, same as their official webpack example behaviour.

You can test once and proceed.

@jakoblind
Copy link
Owner

Nice! I experimented a bit and found it that we can also pass --content-base as argument to webpack-dev-server instead of putting it in webpack.config.js. I like that solution better because it makes the first impression of the webpack.config.js less scary for newbies.

"start": "webpack-dev-server --hot --mode development --content-base ./dist"

@theajr
Copy link
Contributor Author

theajr commented Oct 22, 2019

of-course, but most of webpack config can also be done through arguments, we should either go with arguments approach or config file. Having some configuration in scripts and some config in webpack.config.js will confuse the newbie more in my opinion. I personally prefer webpack.config.js.

Let me know if you want me to make changes to handle --content-base though arguments.

@jakoblind
Copy link
Owner

I see your point. However we already pass in --hot which could be in webpack.config.js. I like that we extract the webpack-dev-server specific config to arguments and keep only config that is used in the production build in webpack.config.js.

@theajr
Copy link
Contributor Author

theajr commented Oct 22, 2019

@jakoblind Yeah, I agree with this. So we can move development config to arguments and production config to webpack.config.json, which makes more sense instead of having dev and production webpack config files.
We should refactor the existing code in this case.

For now you can merge this, we will refactor after adding rollup support all together. What do you say?

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

Successfully merging this pull request may close these issues.

2 participants