梗概:

  • 配置监听代码变动, 并自动执行打包构建的功能
  • 需要先安装依赖库: webpack-dev-server

使用方法:

  • npm脚本上添加: “start”:“webpack serve —open”

实例

devServer: {
    proxy: { // proxy URLs to backend development server
      '/api': ' http://localhost:3000 '
    },
    static: path. join (__dirname, 'public'), // boolean | string | array | object, static file location
    compress: true, // enable gzip compression
    historyApiFallback: true, // true for index. html upon 404, object for multiple paths
    hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
    https: false, // true for self-signed, object for cert authority
    // ...
  },