yarn add -D webpack-dev-server
加在scripts裏。webpack
"scripts": { "build:dev": "webpack --config build/webpack.config.dev.js", "build:prod": "webpack --config build/webpack.config.prod.js", "start:dev": "webpack-dev-server --config build/webpack.config.dev.js", "start:prod": "webpack-dev-server --config build/webpack.config.prod.js" }
yarn start:dev yarn start:prod
啓動後,瀏覽器打開http://localhost:8080web
只須要在後面加 --port [端口號]
就能夠了json
"start:prod": "webpack-dev-server --config build/webpack.config.prod.js --port 9090"