Browse Source

feat: add build report

i18n
xiaoxian521 3 years ago
parent
commit
9e5fe5edbc
  1. 6
      build/plugins.ts
  2. 2
      package.json
  3. 65
      pnpm-lock.yaml

6
build/plugins.ts

@ -6,11 +6,13 @@ import WindiCSS from "vite-plugin-windicss";
import { viteMockServe } from "vite-plugin-mock"; import { viteMockServe } from "vite-plugin-mock";
import liveReload from "vite-plugin-live-reload"; import liveReload from "vite-plugin-live-reload";
import ElementPlus from "unplugin-element-plus/vite"; import ElementPlus from "unplugin-element-plus/vite";
import { visualizer } from "rollup-plugin-visualizer";
import removeConsole from "vite-plugin-remove-console"; import removeConsole from "vite-plugin-remove-console";
import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor"; import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor";
export function getPluginsList(command, VITE_LEGACY) { export function getPluginsList(command, VITE_LEGACY) {
const prodMock = true; const prodMock = true;
const lifecycle = process.env.npm_lifecycle_event;
return [ return [
vue(), vue(),
// jsx、tsx语法支持 // jsx、tsx语法支持
@ -97,6 +99,10 @@ export function getPluginsList(command, VITE_LEGACY) {
targets: ["ie >= 11"], targets: ["ie >= 11"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"] additionalLegacyPolyfills: ["regenerator-runtime/runtime"]
}) })
: null,
// 打包分析
lifecycle === "report"
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
: null : null
]; ];
} }

2
package.json

@ -10,6 +10,7 @@
"dev": "cross-env --max_old_space_size=4096 vite", "dev": "cross-env --max_old_space_size=4096 vite",
"serve": "pnpm dev", "serve": "pnpm dev",
"build": "rimraf dist && cross-env vite build", "build": "rimraf dist && cross-env vite build",
"report": "rimraf dist && cross-env vite build",
"preview": "vite preview", "preview": "vite preview",
"preview:build": "pnpm build && vite preview", "preview:build": "pnpm build && vite preview",
"clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install", "clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install",
@ -87,6 +88,7 @@
"prettier": "2.3.2", "prettier": "2.3.2",
"pretty-quick": "3.1.1", "pretty-quick": "3.1.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"rollup-plugin-visualizer": "^5.5.4",
"sass": "^1.49.0", "sass": "^1.49.0",
"sass-loader": "^12.4.0", "sass-loader": "^12.4.0",
"stylelint": "13.13.1", "stylelint": "13.13.1",

65
pnpm-lock.yaml

@ -54,6 +54,7 @@ specifiers:
responsive-storage: ^1.0.11 responsive-storage: ^1.0.11
rgb-hex: ^4.0.0 rgb-hex: ^4.0.0
rimraf: 3.0.2 rimraf: 3.0.2
rollup-plugin-visualizer: ^5.5.4
sass: ^1.49.0 sass: ^1.49.0
sass-loader: ^12.4.0 sass-loader: ^12.4.0
stylelint: 13.13.1 stylelint: 13.13.1
@ -136,6 +137,7 @@ devDependencies:
prettier: 2.3.2 prettier: 2.3.2
pretty-quick: 3.1.1_prettier@2.3.2 pretty-quick: 3.1.1_prettier@2.3.2
rimraf: 3.0.2 rimraf: 3.0.2
rollup-plugin-visualizer: 5.5.4
sass: 1.49.0 sass: 1.49.0
sass-loader: 12.4.0_sass@1.49.0 sass-loader: 12.4.0_sass@1.49.0
stylelint: 13.13.1 stylelint: 13.13.1
@ -2718,6 +2720,14 @@ packages:
engines: { node: ">=0.10.0" } engines: { node: ">=0.10.0" }
dev: true dev: true
/define-lazy-prop/2.0.0:
resolution:
{
integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==
}
engines: { node: ">=8" }
dev: true
/diff/4.0.2: /diff/4.0.2:
resolution: resolution:
{ {
@ -4143,6 +4153,15 @@ packages:
} }
dev: true dev: true
/is-docker/2.2.1:
resolution:
{
integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
}
engines: { node: ">=8" }
hasBin: true
dev: true
/is-extglob/2.1.1: /is-extglob/2.1.1:
resolution: { integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= } resolution: { integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= }
engines: { node: ">=0.10.0" } engines: { node: ">=0.10.0" }
@ -4259,6 +4278,16 @@ packages:
engines: { node: ">=10" } engines: { node: ">=10" }
dev: true dev: true
/is-wsl/2.2.0:
resolution:
{
integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
}
engines: { node: ">=8" }
dependencies:
is-docker: 2.2.1
dev: true
/isexe/2.0.0: /isexe/2.0.0:
resolution: { integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= } resolution: { integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= }
dev: true dev: true
@ -4998,6 +5027,18 @@ packages:
mimic-fn: 2.1.0 mimic-fn: 2.1.0
dev: true dev: true
/open/8.4.0:
resolution:
{
integrity: sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==
}
engines: { node: ">=12" }
dependencies:
define-lazy-prop: 2.0.0
is-docker: 2.2.1
is-wsl: 2.2.0
dev: true
/optionator/0.9.1: /optionator/0.9.1:
resolution: resolution:
{ {
@ -6128,6 +6169,22 @@ packages:
glob: 7.2.0 glob: 7.2.0
dev: true dev: true
/rollup-plugin-visualizer/5.5.4:
resolution:
{
integrity: sha512-CJQFUuZ75S1daGEkk62UH7lL6UFCoP86Sn/iz4gXBdamdwFeD5nPGCHHXfXCrly/wNgQOYTH7cdcxk4+OG3Xjw==
}
engines: { node: ">=12" }
hasBin: true
peerDependencies:
rollup: ^2.0.0
dependencies:
nanoid: 3.2.0
open: 8.4.0
source-map: 0.7.3
yargs: 17.3.1
dev: true
/rollup/2.66.1: /rollup/2.66.1:
resolution: resolution:
{ {
@ -6363,6 +6420,14 @@ packages:
} }
engines: { node: ">=0.10.0" } engines: { node: ">=0.10.0" }
/source-map/0.7.3:
resolution:
{
integrity: sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
}
engines: { node: ">= 8" }
dev: true
/sourcemap-codec/1.4.8: /sourcemap-codec/1.4.8:
resolution: resolution:
{ {

Loading…
Cancel
Save