启动本地服务

本地开发服务需要安装webpack-dev-server,然后在配置中可以使用devServer属性进行配置。官方文档:https://webpack.docschina.org/configuration/dev-server/

devServer: {
  host: '0.0.0.0',
  port: 2333,
  // 开启gzip
  compress: true,
  // 自动打开浏览器
  open: true,
  // 配置代理
  proxy: {
    '/api': {
      target: 'http://localhost:3000',
      pathRewrite: { '^/api': '' },
    }
  },
  // 热更新
  hot: true
}

results matching ""

    No results matching ""