编译框架

2020-04-09  本文已影响0人  无花无酒_3cd3

//es6代码编译
const TerserPlugin = require('terser-webpack-plugin-legacy')

new TerserPlugin({
  sourceMap: config.build.productionSourceMap,
  parallel: true
}),

webpack.base.conf这个文件夹,rules:第一行添加
编译加速https://www.webpackjs.com/loaders/thread-loader/

const cpus = require('os').cpus()  //获取cpu信息
console.log(cpus)
  npm install  thread-loader -D


   rules: [
      {
        test: /\.js$/,
        include: path.resolve("src"),
        use: [
          {
            loader: "thread-loader",
            options: {
              workers: 2,
              workerParallelJobs: 20,
              workerNodeArgs: ['--max-old-space-size=1024'],
              poolRespawn: false,
              poolTimeout: 2000,
              poolParallelJobs: 50,
              name: "zto-pool"
            }
          },
          "vue-loader",
          "babel-loader",
          'url-loader'
        ]
      },
      ...(config.dev.useEslint ? [createLintingRule()] : []),
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
 {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [
          resolve('src'),
          resolve('test'),
          resolve('node_modules/webpack-dev-server/client'),
          resolve('node_modules/element-ui/src'),
          resolve('node_modules/vue-localStorage'),
          resolve('node_modules/element-ui/packages')
        ]
      },
上一篇下一篇

猜你喜欢

热点阅读