I place server.js in the projects folder, inside this folder is the src folder. When you run node server.js, this config uses index.html which is in the projects folder, how to make it so that when you start node server.js, it will run html which lies in the src folder?

server.js

const webpack = require("webpack"); const WebpackDevServer = require("webpack-dev-server"); const webpackConfig = require("./webpack.config"); const server = new WebpackDevServer(webpack(webpackConfig), { publicPath: webpackConfig.output.publicPath, hot: true, historyApiFallback: true }); server.listen(3000, "localhost", (err, result) => { if (err) { return console.log(err); } console.log("Listening at http://localhost:3000/"); return 0; }); 

webpack.config.js

 const path = require("path"); const webpack = require("webpack"); module.exports = { devtool: "eval", entry: { Application: [ "webpack-dev-server/client?http://localhost:3000", "webpack/hot/only-dev-server", "./src/Scripts/index" ] }, output: { path: path.join(__dirname, "src", "Build"), filename: "[name].js", publicPath: path.join("src", "Build") }, plugins: [ new webpack.HotModuleReplacementPlugin() ], module: { loaders: [{ test: /\.js$/, loaders: ["react-hot", "babel"], include: path.join(__dirname, "src") }] } }; 
  • one
    Rewrite .webpack.config (which you don’t consider to be necessary) obviously. - Dmitriy Simushev
  • Added by webpack config - Pavel

1 answer 1

So that all requests are forwarded to src in some way:

 const server = new WebpackDevServer(webpack(webpackConfig), { publicPath: webpackConfig.output.publicPath, hot: true, historyApiFallback: true, contentBase: __dirname + '/sec' });