Webpack 4 Tutorial 13: Webpack dev server

preview_player
Показать описание
Let us learn about webpack dev server.

------------
Don't forget to subscribe and like the video if you enjoyed :)
Рекомендации по теме
Комментарии
Автор

Apparently with the latest version of webpack-cli (4.2.0) running dev is a little bit different:

change "dev" "webpack serve" in package.json:

"scripts": {
"dev": "webpack serve",

"build": "rm -rf build && webpack"
}

optionally add the open section in webpack.config.js to automagically load the webpage:

devServer: {
port: 1234,
contentBase: path.join(__dirname, 'dist'),
open: {
app: ['Chrome', '--incognito']
}
}

The above works for:
"path": "^0.12.7",
"webpack": "^5.8.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"

Enjoy,
Maarten

SoftAsInSoftware
Автор

quick question : Where is /assets/ folder

JaySinhaNZ
Автор

if your terminal is throwing error for "contentBase" unknown property. Just replace it with "static"

mohitmohlia
Автор

I'm implementing webpack for my company and am over my head. Is the dev server good to use for a medium company?
I am currently using the proxy server to send ajax to the backend. But I suspect that this won't work on the production server due to differing ports and such. How do you handle this on a larger scale.

sagebias
Автор

why u added <script
??? wont web pack add this on its own ?

yashchauhan
Автор

Thank you for this content!
I also got the error for "contentBase" and the way how it was fixed was by adding this line instead of contentBase:

Instead of:
devServer: {
port: 1234,
contentBase: path.join(__dirname, "dist")
},

I did this and it worked perfectly:
devServer: {
port: 1234,
static: './dist',
},

codingsuccessfully
Автор

Copied this word for word. Didn't work! 'Could not find webpack-dev-server.js in node_modules', even though I checked and it's definitely there. very strange.

richardcross