webpack 打包性能优化

开启多线程打包 thread-loader

https://www.npmjs.com/package/thread-loader

https://github.com/webpack-contrib/thread-loader

module.exports = {
module: {
rules: [
{
test: /\.js$/,
include: path.resolve('src'),
use: [
'thread-loader',
// your expensive loader (e.g babel-loader)
],
},
],
},
};
use: [
{
loader: 'thread-loader',
// loaders with equal options will share worker pools
options: {
// the number of spawned workers, defaults to (number of cpus - 1) or
// fallback to 1 when require('os').cpus() is undefined
workers: 2, // number of jobs a worker processes in parallel
// defaults to 20
workerParallelJobs: 50, // additional node.js arguments
workerNodeArgs: ['--max-old-space-size=1024'], // Allow to respawn a dead worker pool
// respawning slows down the entire compilation
// and should be set to false for development
poolRespawn: false, // timeout for killing the worker processes when idle
// defaults to 500 (ms)
// can be set to Infinity for watching builds to keep workers alive
poolTimeout: 2000, // number of jobs the poll distributes to the workers
// defaults to 200
// decrease of less efficient but more fair distribution
poolParallelJobs: 50, // name of the pool
// can be used to create different pools with elsewise identical options
name: 'my-pool',
},
},
// your expensive loader (e.g babel-loader)
];

prewarming 预热


const threadLoader = require('thread-loader'); threadLoader.warmup(
{
// pool options, like passed to loader options
// must match loader options to boot the correct pool
},
[
// modules to load
// can be any module, i. e.
'babel-loader',
'babel-preset-es2015',
'sass-loader',
]
);

为防止启动工作程序时出现高延迟,可以预热工作程序池。

这将引导池中的最大工作程序数量,并将指定的模块加载到node.js模块高速缓存中。

refs

shit 翻译

https://webpack.docschina.org/loaders/thread-loader/

Lerna

https://zzk.cnblogs.com/my/s/blogpost-p?Keywords=Lerna



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


最新文章

  1. Webform 文件上传、 C#加图片水印 、 图片验证码
  2. 【VB6】VB6实现拖拽
  3. App开发流程之使用分类(Category)和忽略编译警告(Warning)
  4. View和ViewImage设置图片
  5. [问题2015S12] 复旦高等代数 II(14级)每周一题(第十三教学周)
  6. js中Dom对象的position属性
  7. python3 入门 (三) 函数与lambda表达式、闭包
  8. webservice发布在外网上的在system.web中加入这个就好使了
  9. DBA_在Linux上安装Oracle Database11g数据库(案例)
  10. 从浏览器的console获取angularjs的scope
  11. 配置并学习微信JS-SDK(1)
  12. 数据库管理工具神器-DataGrip,可同时管理多个主流数据库[SQL Server,MySQL,Oracle等]连接
  13. [M$]重装或更换主板后提示“由于指定产品密钥激活次数“ office 2016
  14. vue——router
  15. 绑定到外部验证服务LDAP、配置 autofs
  16. [AT2384] [agc015_f] Kenus the Ancient Greek
  17. 不平衡分类学习方法 --Imbalaced_learn
  18. Linux可以明文传输密码的工具sshpass
  19. 【微信小程序】微信小程序wx.previewImage预览图片
  20. 转!! 关于jsp编码设置 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

热门文章

  1. GRASP职责分配模式
  2. ACID 原子性(atomicity,或称不可分割性)、一致性(consistency)、隔离性(isolation,又称独立性)、持久性(durability)。
  3. 房产基于Swoole的PHP RPC框架设计
  4. (Oracle)误删oracle表结构恢复
  5. 虚函数表-C++多态的实现原理
  6. (十二)整合 Shiro 框架,实现用户权限管理
  7. Java——Math,Set,List,map相关练习
  8. sqlite安装与封装后编译
  9. shell(shell变量、条件表达式、流程控制)
  10. 关于SANGFOR AC记录上网记录