-2

Here is my package.json :

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack serve  --hot --open",
    "build": "webpack --config webpack.config.js --mode production"
  },

Here is my webpack.config.js

module.exports = {
  entry: "./src/index.js",
  output: {
    filename: "bundle.[hash].js",
    path: path.resolve(__dirname, "dist"),
  },

I would like to run react on port 8017.

I have found a solution in SO saying I should add these lines to my webpack :

devServer: {
    inline:true,
    port: 8017
  },

Does it mean I need to add a new line in my package.json ?

fransua
  • 501
  • 2
  • 18

1 Answers1

0

Simply add the proper parameter in your webpack.config.js. Have a look on the official documentation of webpack (https://webpack.js.org/configuration/dev-server/#devserver). It should look like this:

module.exports = {
  entry: "./src/index.js",
  devServer: {
  ...your custom devServer config,
  port: 8017,
  },
  output: {
    filename: "bundle.[hash].js",
    path: path.resolve(__dirname, "dist"),
  },
};
Konflex
  • 465
  • 3
  • 11