多进程打包是需要安装
thread-loader
使用多进程打包是有利有弊的, 因为进程的启动需要 600ms , 进程通信也有开销,只有工作中消耗时间比较长的 loader 才需要多进程打包。
安装: npm i -D thread-loader
使用: thread-loader
module.exports = {module: {rules: [// js 兼容 babel{test: /\.js$/,exclude: /node_modules/,use: [// 使用多进程打包babel{loader: 'thread-loader',options: {workers: 2 // 2个进程}},{loader: 'babel-loader',options: {presets: ['@babel/preset-env']}}]},]}}
一般使用了 thread-loader 后打包时间更长了
