美文网首页
编译框架

编译框架

作者: 无花无酒_3cd3 | 来源:发表于2020-04-09 14:57 被阅读0次

    //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')
            ]
          },
    

    相关文章

      网友评论

          本文标题:编译框架

          本文链接:https://www.haomeiwen.com/subject/alscmhtx.html