1、多进程/多实例构建:
资源并行解析可选方案
可选thread-loader或者 HappyPack或者parallel-webpack
2、多进程/多实例:
使用 HappyPack 解析资源
原理:每次 webapck 解析一个模块,HappyPack 会将它及它的依赖分配给 worker 线程中
const HappyPack = require('happypack');
{
module: {
rules: [
{
test: /.js$/,
//include: path.resolve('src'),
use: [
// {
// loader: 'thread-loader',
// options: {
// workers: 3
// }
// },
// 'cache-loader',
// 'babel-loader',
'happypack/loader'
// 'eslint-loader'
]
},
]
},
plugins: [
new Happy1Pack({
// 3) re-add the loaders you replaced above in #1:
loaders: [ 'babel-loader?cacheDirectory=true' ]
}),
]
}
3、多进程/多实例:使用 thread-loader 解析资源
原理:每次 webpack 解析一个模块,thread- loader 会将它及它的依赖分配给 worker 线程中
module: {
rules: [
{
test: /.js$/,
//include: path.resolve('src'),
use: [
{
loader: 'thread-loader',
options: {
workers: 3
}
},
'babel-loader',
'eslint-loader'
]
},