To run a Node express server using webpack-dev-server, we run the webpack-dev-server
command.
For instance, we write
const express = require("express");
const app = express();
require("./_routes")(app);
app.set("port", 8080);
app.listen(app.get("port"), () => {
console.log("Node App Started");
});
to add an Express app in dev-server.js
Then in package.json, we write
{
"scripts": {
"start": "webpack --progress --colors",
"dev-server": "node dev-server.js",
"dev-client": "webpack-dev-server --port 3000"
}
}
to add the dev-client script to run "webpack-dev-server
in the dev-client
script on port 3000.