1·npm install webpack-dev-server -D
2.webpack.config.js
const path=require('path');
const webpack=require('webapck');
module.exports={
devServer:{
contentBase:'./dist',
compress:true,
open:true,//自动开启浏览器
port:9000,
hot:true,//热更新
proxy:{
'/api': {
target:'http://localhost:3000',
pathRewrite: {'^/api':' '}
}
}
},
plugins:[
new webpack.HotModuleReplacementPlugin()
//热更新
]
};
3.package.json
"script ":{
"dev": "webpack-dev-server"
}