-
Notifications
You must be signed in to change notification settings - Fork 29
Running a workflow
Drew Machat edited this page Aug 6, 2016
·
1 revision
Hitting npm run build
all the time will get boring eventually. Fortunately we can work around that quite easily. Let's set up webpack-dev-server
.
As a first step, hit npm i webpack-dev-server --save
. In addition we'll need to tweak package.json
scripts section to include it. Here's the basic idea:
package.json
{
"scripts": {
"build": "webpack --config config/webpack.config.js",
"dev": "webpack-dev-server --devtool eval --config config/webpack.config.js --progress --colors --hot --content-base build"
}
}
When you run npm run dev
from your terminal it will execute the command stated as a value on the dev property. This is what it does:
-
webpack-dev-server
- Starts a web service on localhost:8080 -
--devtool eval
- Creates source urls for your code. Making you able to pinpoint by filename and line number where any errors are thrown -
--config config/webpack.config.js
- If you followed the directory structure from Getting Started, this points webpack to the relative config file -
--progress
- Will show progress of bundling your application -
--colors
- Yay, colors in the terminal! -
--content-base build
- Points to the output directory configured
To recap, when you run npm run dev
this will fire up the webservice, watch for file changes and automatically rebundle your application when any file changes occur. How neat is that!
Go to http://localhost:8080 and you should see something.