webpack dev server port

2019-09-08 15:22发布

I need to change which port webpack-dev-server listen to.

Up to now, I've created these there files:

1条回答
混吃等死
2楼-- · 2019-09-08 15:51

If you have not created a package.json file it will be good if you make one and have a code block like this:

{
  "name": "someName",
  "description": "description",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --host 0.0.0.0 --port 8080 --devtool eval --progress --colors",
    "build": "NODE_ENV=production webpack --config webpack.config.prod.js -p"
  },
  "dependencies": {
    "babel-polyfill": "^6.16.0",
    "html-webpack-plugin": "^2.24.1",
    "react": "^15.3.2",
    "react-dom": "^15.3.2",
    "react-router": "^3.0.0",
    "redux": "^3.6.0"
  },
  "devDependencies": {
    "babel-core": "^6.17.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.16.2"
  },
  "babel": {
    "presets": [
      "es2015",
      "react"
    ],
    "plugins": [
      "transform-runtime",
      "transform-object-rest-spread"
    ]
  }
}

You may remove the un used modules. Then run : npm start And it will run on port 8080

If you start your dev server without package.json. You may simply run following from terminal.

webpack-dev-server --host 0.0.0.0 --port 8080
查看更多
登录 后发表回答