yarn add webpack-dev-server
const Webpack = require('webpack')module.exports = {devServer: {contentBase: './public', // 为devServer指定静态资源目录(不包括打包资源),如public/favor.icon,可以接受字符串,也可以接受一个数组,数组中存放目录// hot: true, // 开启热更新 如果有文件发生改动,热更新失败,则会自动回退到自动刷新页面,会导致捕捉不到错误hotOnly: true, // 如果改成hotOnly,有文件发生改动,热更新失败,则不会回退到自动刷新页面,能更好的帮我们定位错误proxy: {'^/api': {// http://localhost:8080/api/users => https://api.github.com/api/userstarget: 'https://api.github.com',pathRewrite: {'^/api': '' // https://api.github.com/api/users => https://api.github.com/users},changeOrigin: true}}},plugins: [new Webpack.HotModuleReplacementPlugin()]}
