Using webpack with react and nodejs pug file

Viewed 14

Am using react with webpack and i would like use the development option with nodejs view file

So i have the following webpack config file

let config = {
 entry: './src/index.js',
 output: {
    publicPath: '/',
    path: __dirname,
    filename: 'app.bundle.js'
 },
 resolve: {
    extensions: ['.js', '.jsx', '.json', '.ts', '.tsx']
 },
 devServer: {
    port: 9000,
    headers: {
        'Access-Control-Allow-Origin': '*',
    },
},
module: {
    rules: [
        { test: /\.(js|jsx)$/, exclude: /node_modules/,
            use: {   loader: 'babel-loader' },
        },

        {
            test: /\.s[ac]ss$/i,
            use: ["style-loader", "css-loader","sass-loader",
            ],
        },
    ]
 },
};

module.exports = config;

IN my nodejs pug file i have added the following

html
head
body
    div#root
        script(type="text/javascript", src="http://localhost:9000/app.bundle.js")

and my nodejs is running on port 5000 The above works but during hot update it fails to automatically update changes done on react.

On the console during hot update it shows

 GET http://localhost:5000/main.487dc444df35bc7a7c7d.hot-update.json net::ERR_CONNECTION_REFUSED

How can i resolve this for the hot update to also work?

0 Answers
Related