mode:'development',
devServer:{
//运行代码的目录
contentBase:resolve(__dirname,'build'),
//监视 contentBase 目录下的所有文件,一但文件变化就会 reload (重新打包,重新加载浏览器)
watchContentBase:true,
//忽略某些文件
watchOptions:{
ignored:/node_modules/
},
//启动gzip
compress:true,
//端口
port:3000,
//自动打开浏览器
open:true,
//开启HMR功能
hot:true,
// 不要显示启动服务器日志
clientLogLevel:'none',
//除了一些基本自动信息以外,其他内容都不要显示
quiet:true,
//如果出错了,不要进行全屏提示
overlay:false,
//服务器代理 -->解决开发环境跨域问题
proxy:{
//一旦devserver服务器(5000)接收到请求 /api 开头的请求,就会转发到另一个服务器(3000)
'/api':{
target:'http://localhost:3000',
//发送请求时,请求路径重写
pathRewrite:{
'/^/api/':''
}
}
}
},