设置webpack-dev-server
安装
npm install webpack-dev-server –s -d
配置
devServer: { // 配置开发服务功能
contentBase: path.resolve(__dirname, 'dist'),
host: '192.168.3.34', // localhost
compress: true,
port: 8082 // 80
}
命令
"scripts": {
"server":"webpack-dev-server"
},
加上 --open 自动打开页面
"scripts": {
"server": "webpack-dev-server --open",
},
运行
npm run server