webpack dev server port

馋奶兔 提交于 2019-12-25 08:00:06

问题


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

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

  • webpack.common.js
  • webpack.dev.js
  • webpack.prod.js

回答1:


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


来源:https://stackoverflow.com/questions/41141470/webpack-dev-server-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!