devServer: { // 运行代码的目录 contentBase: resolve(__dirname, 'build'), // 监视contentBase目录下的所有文件,一旦有变化就会reload watchContentBase: true, watchOptions:{ // 忽略文件 ignored: /node_modules/ }, // 启动gzip压缩 compress: true, // 端口号 port: 5000, // 域名 host: 'localhost', // 自动打开浏览器 open: true, // 开启HMR功能 hot: true, // 不要显示启动服务器的日志 clientLogLevel: 'none', // 除了一些基本启动信息外,其他内容都不要显示 quiet: true, // 如果出现错误信息,不要全屏提示 overlay: false, // 服务器代理,解决开发环境下跨域问题 proxy: { // 一旦devserver(5000)服务器接收到 /api/xxx的请求,就会把请求转发到另外一个服务器(3000) '/api': { target: 'http://localhost:3000', // 发送请求时,请求路径重写:将/api/xxx -> /xxx(去掉/api) pathRewrite:{ '^/api': '' } } } }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232004.html原文链接:https://javaforall.net
