当前位置: 首页 > news >正文

可视化构建包分析报告

一、webpack

使用 webpack-bundle-analyzer 插件即可。

安装:npm install webpack-bundle-analyzer -D

使用:new BundleAnalyzerPlugin(options?: object)

Name Type Description
analyzerMode One of: server, static, json, disabled Default: server. In server mode analyzer will start HTTP server to show bundle report. In static mode single HTML file with bundle report will be generated. In json mode single JSON file with bundle report will be generated. In disabled mode you can use this plugin to just generate Webpack Stats JSON file by setting generateStatsFile to true.
analyzerHost {String} Default: 127.0.0.1. Host that will be used in server mode to start HTTP server.
analyzerPort {Number} or auto Default: 8888. Port that will be used in server mode to start HTTP server. If analyzerPort is auto, the operating system will assign an arbitrary unused port
analyzerUrl {Function} called with { listenHost: string, listenHost: string, boundAddress: server.address}. server.address comes from Node.js Default: http:// l i s t e n H o s t : {listenHost}: listenHost:{boundAddress.port}. The URL printed to console with server mode.
reportFilename {String} Default: report.html. Path to bundle report file that will be generated in static mode. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).
reportTitle {String|function} Default: function that returns pretty printed current date and time. Content of the HTML title element; or a function of the form () => string that provides the content.
defaultSizes One of: stat, parsed, gzip Default: parsed. Module sizes to show in report by default. Size definitions section describes what these values mean.
openAnalyzer {Boolean} Default: true. Automatically open report in default browser.
generateStatsFile {Boolean} Default: false. If true, webpack stats JSON file will be generated in bundle output directory
statsFilename {String} Default: stats.json. Name of webpack stats JSON file that will be generated if generateStatsFile is true. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).
statsOptions null or {Object} Default: null. Options for stats.toJson() method. For example you can exclude sources of your modules from stats file with source: false option. See more options here.
excludeAssets {null|pattern|pattern[]} where pattern equals to {String|RegExp|function} Default: null. Patterns that will be used to match against asset names to exclude them from the report. If pattern is a string it will be converted to RegExp via new RegExp(str). If pattern is a function it should have the following signature (assetName: string) => boolean and should return true to exclude matching asset. If multiple patterns are provided asset should match at least one of them to be excluded.
logLevel One of: info, warn, error, silent Default: info. Used to control how much details the plugin outputs.

配置webpack

// webpack.config.js 文件const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports={plugins: [new BundleAnalyzerPlugin({analyzerMode: "static",analyzerPort: 8888,reportFilename: "report.html",openAnalyzer: true,generateStatsFile: false,})// 默认配置的具体配置项// new BundleAnalyzerPlugin({//   analyzerMode: 'server',//   analyzerHost: '127.0.0.1',//   analyzerPort: '8888',//   reportFilename: 'report.html',//   defaultSizes: 'parsed',//   openAnalyzer: true,//   generateStatsFile: false,//   statsFilename: 'stats.json',//   statsOptions: null,//   excludeAssets: null,//   logLevel: info// })]
}

配置package.json 文件

-V, --version 输出版本号
-m, --mode 分析器模式。应该是“server”、“static”或“ json”。
In server mode analyzer will start HTTP server to show bundle report.
In static mode single HTML file with bundle report will be generated.
In json mode single JSON file with bundle report will be generated. (default: server)
在“server”模式下,分析器将启动 HTTP 服务器来显示捆绑报告。
在“static”模式下,将生成包含报告的单个 HTML 文件。
在“json”模式下,将生成带有捆绑报告的单个 JSON 文件(默认值: 服务器)。
-h, --host 将在“server”模式下用于启动 HTTP 服务器的主机。(默认值: 127.0.0.1)
-p, --port 端口将用于在“server”模式启动 HTTP 服务器。应该是一个数字或“auto”(默认值: 8888)
-r, --report 将在“ static”模式下生成的绑定报告文件的路径(默认值: report.html)
-t, --title 在 html 报告的 title 元素中使用的字符串<br/> -s, --default-sizes 默认情况下在树映射中显示的模块大小。<br/> 可能的值: stat、 parsed、 gzip (默认值: parsed)<br/> -O, --no-open 不要在默认浏览器中自动打开报表。<br/> -e, --exclude 应该从报告中排除的资产。<br/> 可以多次指定。<br/> -l, --log-level 日志分级。<br/> 可能的值: 调试,信息,警告,错误,静默(默认值: 信息)<br/> -h, --help 输出用量信息输出用量信息

{"scripts": {"build": "node build/build.js","build:analyzer": "use_analyzer=true npm run build --report",}
}

效果:
执行命令:npm run build:analyzer

二、Rollup(vite)

使用 rollup-plugin-visualizer 插件即可。

安装:npm install -D rollup-plugin-visualizer

使用:
filename (string, default stats.{ext depending template}) - name of the file with diagram to generate

title (string, default Rollup Visualizer) - title tag value

open (boolean, default false) - Open generated file in default user agent

template (string, default treemap) - Which diagram type to use: sunburst, treemap, network, raw-data, list.

gzipSize (boolean, default false) - Collect gzip size from source code and display it at chart.

brotliSize (boolean, default false) - Collect brotli size from source code and display it at chart.

Advanced options (touch only if you really need it):
emitFile (boolean, default false) - Use rollup’s emitFile to generate file. Useful if you want to control all output in one place (via rollup output options). This also could be usefull with svelte as it calls vite several times.

sourcemap (boolean, default false) - Use sourcemaps to calculate sizes (e.g. after UglifyJs or Terser). Always add plugin as last option.

projectRoot (string | RegExp, default process.cwd()) - This is some common root(s) path to your files. This is used to cut absolute files paths out.

include (Filter | Filter[], default undefined) - Filter for inclusion

exclude (Filter | Filter[], default undefined) - Filter for exclusion

Filter type is { bundle?: picomatchPattern, file?: picomatchPattern }

Note about include and exclude - If options.include is omitted or has zero length, filter will return true by default. Otherwise, an ID must match one or more of the picomatch patterns, and must not match any of the options.exclude patterns. This entries will not be included in stats at all.

配置vite

import { visualizer } from "rollup-plugin-visualizer";module.exports = {plugins: [visualizer({filename: './node_modules/.cache/report.html',open: true})],
};

配置package.json 文件

{"scripts": {"build:only": "vite build","build:mode": "vite build --mode report",}
}

效果:
执行命令:npm run build:mode

相关文章:

可视化构建包分析报告

一、webpack 使用 webpack-bundle-analyzer 插件即可。 安装&#xff1a;npm install webpack-bundle-analyzer -D 使用&#xff1a;new BundleAnalyzerPlugin(options?: object) Name Type Description analyzerMode One of: server, static, json, disabled Default: se…...

统一git使用方法,git状态变迁图,git commit提交规范

目录 说明 统一git使用方法 git状态变迁图 git commit 提交规范 说明 多次工作中多名员工不懂git多次技术分享&#xff0c;自行查资料学习git并使用&#xff0c;会出现使用各种偏僻的命令&#xff0c;异常问题无法解决&#xff1b;或出现带url的git合并提交。主要是学的不…...

react与vue的区别

React和Vue.js是两个流行的JavaScript库/框架&#xff0c;用于构建用户界面。以下是React和Vue之间的一些主要区别&#xff1a; 学习曲线&#xff1a;Vue.js对于新手来说比React更容易学习和上手。 构建方式&#xff1a;React强调组件的可重用性&#xff0c;而Vue.js更注重模板…...

成功解决SQL 错误 [22000]: 第3 行附近出现错误: 试图修改自增列[ID](达梦数据库)

当我们使用工具来手动修改自增列的自增ID时&#xff0c;可能会报如下异常 SQL 错误 [22000]: 第3 行附近出现错误:试图修改自增列[ID] 解决办法&#xff1a; 可以使用SQL语句来修改 ALTER TABLE "fdw"."SYSTEM_DICT_TYPE" DROP IDENTITY; UPDATE "f…...

【算法】活用双指针完成复写零操作

Problem: 1089. 复写零 文章目录 题目解析算法原理分析找到最后一个复写的位置从后往前进行复写操作 代码展示 题目解析 首先我们来分析一下本题的题目意思 可以看到题目中给到了一个数组&#xff0c;意思是让我们将数组中的零元素都复写一遍&#xff0c;然后将其余的元素向后平…...

【面试高频题】难度 3/5,字典树热门运用题

题目描述 这是 LeetCode 上的 「745. 前缀和后缀搜索」 &#xff0c;难度为 「困难」。 Tag : 「字典树」 设计一个包含一些单词的特殊词典&#xff0c;并能够通过前缀和后缀来检索单词。 实现 WordFilter 类&#xff1a; WordFilter(string[] words) 使用词典中的单词 words 初…...

vue base64图片转file流 下载到本地 或者上传

<img :src"data:image/png;base64,form.img" style"max-width:280px;max-height: 280px;margin: auto;" />// base64 转file const base64ToFile()>{let byImg atob(form.img); // 解码base64let n byImg.lengthlet a new Uint8Array(n);while…...

无涯教程-PHP - 简介

PHP 7是最期待的&#xff0c;它是PHP编程语言的主要功能版本。 PHP 7于2015年12月3日发布。本教程将以简单直观的方式教您PHP 7的新功能及其用法。 无涯教程假设您已经了解旧版本的PHP&#xff0c;现在就可以开始学习PHP 7的新功能。 使用下面的示例- <html><head&…...

web基础+HTTP协议+httpd详细配置

目目录录 一、Web基础1.1 HTML概述1.1.1 HTML的文件结构1.1.2 HTML中的部分基本标签 1.3 MIME1.4 URI 和 URL1.4 定义1.4.2 URI 和 URL 的区别 二、静态资源和动态资源2.1 静态资源2.2 动态资源 三、HTTP协议3.1 HTTP协议简介3.2 HTTP协议版本3.2 HTTP方法3.3 HTTP请求访问的完…...

【sql】MongoDB的增删改查分页条件等

【sql】MongoDB的增删改查分页条件等 //增 //新增数据2种方式 db.msg.save({"name":"springboot&#x1f600;"}); db.msg.insert({"name":"mango good"}); db.msg.save({"name":"springboot",type:"工具书&…...

我的动态归纳(便于搜索)

linux dns配置文件是“/etc/resolv.conf”&#xff0c;该配置文件用于配置DNS客户&#xff0c;它包含了主机的域名搜索顺序和DNS/服务器的地址&#xff0c;每一行包括一个关键字和一个或多个空格隔开的参数。 /etc/resolv.conf &#xff08;不配置就不能域名解析&#xff09; 可…...

langchain ChatGPT AI私有知识库

企业知识库 原理就是把文档变为向量数据库&#xff0c;然后搜索向量数据库&#xff0c;把相似的数据和问题作为prompt&#xff0c; 输入到大模型&#xff0c;再利用GPT强大的自然语言处理、推理和分析等方面的能力将答案返回给用户 什么是langchain? langchain是一个强大的…...

API接口常用数据格式Json,Json的定义和XML的区别

现在程序员还有谁不知道 JSON 吗&#xff1f;无论对于前端还是后端&#xff0c;JSON 都是一种常见的数据格式。那么 JSON 到底是什么呢&#xff1f; JSON 的定义 JSON &#xff08;JavaScript Object Notation&#xff09; &#xff0c;是一种轻量级的数据交换格式。它的使用…...

密码学学习笔记(二十一):SHA-256与HMAC、NMAC、KMAC

SHA-256 SHA-2是广泛应用的哈希函数&#xff0c;并且有不同的版本&#xff0c;这篇博客主要介绍SHA-256。 SHA-256算法满足了哈希函数的三个安全属性&#xff1a; 抗第一原像性 - 无法根据哈希函数的输出恢复其对应的输入。抗第二原像性 - 给定一个输入和它的哈希值&#xf…...

操作系统-笔记-第四章-文件管理

目录 四、第四章——文件管理 1、文件管理——基础概念 &#xff08;1&#xff09;文件结构 &#xff08;2&#xff09;操作系统提供的接口 &#xff08;3&#xff09;总结 2、文件的逻辑结构 &#xff08;1&#xff09;有结构文件&#xff08;类似SQL表文件&#xff09…...

【MiniGUI】文字颜色实现透明度变化

在MiniGUi中&#xff0c;输出文字时有时候希望文字带有透明度信息&#xff0c; 即文字能够透出下面的图像来。 很自然地想到&#xff0c;设置颜色时&#xff0c;将颜色设置为带有透明度的颜色&#xff1a; SelectFont(hdc, mg_font);SetTextColor(hdc, RGBA2Pixel(HDC_SCREEN, …...

css中元素加定位之后到一定距离元素会变小

css中元素加定位之后到一定距离元素会变小 主要原因&#xff1a;元素没有加宽高 .swiperWrapper .active{bottom: 380px;left: 215px;z-index: 10; } .swiperWrapper .next{bottom: 170px;left: 7%;z-index: 20; } .swiperWrapper .prev{bottom: 360px;left: 0%;z-index: 30;…...

Java 语言实现冒泡排序

Java 语言实现冒泡排序 介绍 冒泡排序是一种简单直观的排序算法&#xff0c;它重复地比较相邻的两个元素&#xff0c;如果顺序错误就交换它们&#xff0c;直到没有需要交换的元素为止。冒泡排序的思路是通过每一轮的比较将最大&#xff08;或最小&#xff09;的元素逐渐“冒泡…...

面向对象单选题

下列选项中不属于面向对象的特征的是&#xff08;B&#xff09; A、封装性 B、安全性 C、继承性 D、多态性 在Java中,关于继承&#xff0c;类只支持&#xff08;A&#xff09; A、单继承 B、多继承 C、两个都可以 D、两个都不可以 用于定义成员的访问控制权的一组关键字…...

微服务-Fegin

在之前我们两服务之间调用的时候用的是restTemplate,但是这个方式调用存在很多的问题 String url "http://userservice/user/" order.getUserId(); 代码可读性差&#xff0c;编码体验不统一参数复杂的url难以维护 所以我们大力推出我们今天的主角--Fegin Feign是…...

伊朗把以色列命根子炸了,美国现在害怕了,特朗普或下令提前退场

近日&#xff0c;中东局势风云突变&#xff0c;伊朗对以色列发动了一系列精准且致命的打击&#xff0c;直击以色列的“命根子”&#xff0c;令美国深感恐惧&#xff0c;特朗普政府甚至可能下令提前从中东战事中抽身。伊朗此次行动&#xff0c;目标直指以色列的核心战略设施。以…...

Qwen3-32B大模型私有部署教程:WebUI中history上下文管理与截断策略

Qwen3-32B大模型私有部署教程&#xff1a;WebUI中history上下文管理与截断策略 1. 环境准备与快速部署 本教程将指导您在RTX 4090D 24GB显存环境下完成Qwen3-32B模型的私有部署&#xff0c;并重点讲解WebUI中的对话历史管理策略。我们的优化镜像已预装所有必要组件&#xff0…...

Matplotlib 3D绘图进阶技巧:如何让你的图形旋转起来并添加动态效果

Matplotlib 3D动态可视化&#xff1a;从基础旋转到交互式动画的完整指南 在数据科学和工程领域&#xff0c;3D可视化已经成为展示复杂数据关系的强大工具。Matplotlib作为Python生态系统中最经典的可视化库&#xff0c;其3D绘图功能虽然不如一些专业3D库强大&#xff0c;但胜在…...

基于TOTG的ROS机械臂轨迹平滑优化实践:摆脱MoveIt依赖

1. 为什么需要摆脱MoveIt的轨迹规划方案 在ROS生态中&#xff0c;MoveIt一直是机械臂运动规划的事实标准&#xff0c;但实际项目中我们经常遇到这样的困境&#xff1a;当只需要简单的点到点运动时&#xff0c;MoveIt庞大的架构反而成了负担。我曾经在一个仓储分拣项目中使用UR5…...

Ostrakon-VL-8B模型效果深度评测:与Claude、GPT-4V多维度对比

Ostrakon-VL-8B模型效果深度评测&#xff1a;与Claude、GPT-4V多维度对比 最近多模态大模型的热度一直没降下来&#xff0c;各家都在推出自己的“看图说话”模型。除了大家熟悉的GPT-4V和Claude 3系列&#xff0c;一个名叫Ostrakon-VL-8B的新选手也进入了我的视野。它主打一个…...

Qwen-Image镜像惊艳效果:RTX4090D运行Qwen-VL精准解析含中文表格的财务截图

Qwen-Image镜像惊艳效果&#xff1a;RTX4090D运行Qwen-VL精准解析含中文表格的财务截图 1. 开篇&#xff1a;当AI遇到财务表格 想象一下这样的场景&#xff1a;你收到一份财务部门的截图&#xff0c;上面密密麻麻布满了中文表格数据。传统方法可能需要人工逐项录入&#xff0…...

通过adb修改pq_default.ini优化S905X3电视盒硬解画质,告别油画效果

1. 为什么S905X3电视盒硬解画质像油画&#xff1f; 最近一年我一直在用S905X3芯片的电视盒&#xff0c;性能确实比之前的RK3328强不少&#xff0c;但有个问题让我特别头疼——硬解视频时画面总像蒙了一层油&#xff0c;细节全被磨平&#xff0c;人脸像打了十层美颜&#xff0c;…...

用Kettle玩转数据清洗:Excel转MySQL的5个高级技巧(含JNDI配置)

用Kettle玩转数据清洗&#xff1a;Excel转MySQL的5个高级技巧&#xff08;含JNDI配置&#xff09; 在企业级数据处理场景中&#xff0c;数据清洗与迁移的效率直接影响着业务决策的时效性。作为Pentaho旗下的开源ETL工具&#xff0c;Kettle&#xff08;现更名为PDI&#xff09;凭…...

【OpenCV 图像处理实战:从直方图到透视变换全攻略】

本文将系统梳理 OpenCV 中直方图统计、Mask 掩模、直方图均衡化、图像透视变换四大核心技术&#xff0c;结合完整代码与详细解析&#xff0c;带你从基础到进阶掌握图像处理实战技能。一、图像直方图&#xff1a;像素分布的可视化直方图是图像像素灰度级分布的直观表达&#xff…...

小白也能玩转GPT-OSS:20B:一键部署开源大模型全流程

小白也能玩转GPT-OSS:20B&#xff1a;一键部署开源大模型全流程 1. 引言&#xff1a;为什么你需要关注这个“小巨人”模型&#xff1f; 如果你对AI大模型感兴趣&#xff0c;但一听到“本地部署”、“GPU要求”、“复杂配置”就头疼&#xff0c;那么今天这篇文章就是为你准备的…...