From 6c63c557e48afcaa0b612a9e86cee91056bebb4d Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Wed, 15 Jan 2025 22:14:04 +0800 Subject: [PATCH] feat(vconsole-helper): add vconsole-helper --- README.md | 7 +- docs/.vuepress/sidebar-changelog.json | 16 ++ docs/.vuepress/sidebar.json | 22 ++ docs/README.md | 9 +- docs/changelog/plugin-light-shared-vue2.md | 9 + docs/changelog/plugin-light-shared.md | 27 +++ docs/changelog/project-config-uni-vite.md | 79 +++++++ docs/changelog/project-config-uni-vue.md | 12 + docs/changelog/vconsole-helper.md | 21 ++ .../vite-plugin-analyze-bundle-file-size.md | 15 ++ docs/changelog/vite-plugin-dispatch-vue.md | 23 ++ docs/changelog/vite-plugin-gen-version.md | 10 + docs/changelog/vite-plugin-legacy-polyfill.md | 8 + docs/changelog/vite-plugin-replace-keyword.md | 8 + .../webpack-plugin-dispatch-script.md | 24 ++ docs/changelog/webpack-plugin-dispatch-vue.md | 27 +++ docs/changelog/webpack-plugin-gen-version.md | 20 ++ docs/zh/project-config-uni-vite.md | 85 ++++++- docs/zh/vconsole-helper.md | 74 +++++++ docs/zh/vite-plugin-alias-for-library.md | 4 +- .../vite-plugin-analyze-bundle-file-size.md | 43 ++++ docs/zh/vite-plugin-legacy-polyfill.md | 54 +++++ docs/zh/vite-plugin-replace-keyword.md | 45 ++++ docs/zh/webpack-plugin-tailwind.md | 2 +- package.json | 21 +- packages/import-meta-resolve/package.json | 6 +- packages/plugin-light-preprocess/package.json | 4 +- .../plugin-light-shared-vue2/CHANGELOG.md | 9 + .../plugin-light-shared-vue2/package.json | 4 +- .../plugin-light-shared-vue2/src/index.ts | 4 + .../src/uni-cli-shared.ts | 6 + packages/plugin-light-shared/CHANGELOG.md | 27 +++ packages/plugin-light-shared/package.json | 6 +- .../plugin-light-shared/src/config-project.ts | 31 +-- packages/plugin-light-shared/src/config.ts | 37 +++- .../src/core/gen-version/gen-version.ts | 2 +- packages/plugin-light-shared/src/helper.ts | 6 - packages/plugin-light-shared/src/index.ts | 5 +- packages/plugin-light-shared/src/platform.ts | 18 ++ .../package.json | 4 +- .../package.json | 4 +- .../src/index.d.ts | 2 +- packages/project-config-uni-vite/.npmrc | 1 - packages/project-config-uni-vite/CHANGELOG.md | 79 +++++++ packages/project-config-uni-vite/README.md | 85 ++++++- packages/project-config-uni-vite/package.json | 22 +- .../src/chunk-split.ts | 80 +++++++ packages/project-config-uni-vite/src/types.ts | 19 +- .../src/uni-vite-config.ts | 108 +++++++-- packages/project-config-uni-vue/CHANGELOG.md | 12 + packages/project-config-uni-vue/package.json | 6 +- .../project-config-uni-vue/src/external.ts | 10 +- .../src/uni-vue-config.ts | 10 + packages/project-config-vite/package.json | 6 +- packages/project-config-vite/src/cdn.ts | 16 +- .../project-config-vite/src/vite-config.ts | 4 +- packages/project-config-vue/package.json | 6 +- .../project-config-vue/src/base-config.ts | 12 +- packages/project-config-vue/src/config.ts | 23 +- packages/uni-read-pages-vite/package.json | 2 +- packages/vconsole-helper/CHANGELOG.md | 19 ++ packages/vconsole-helper/README.md | 74 +++++++ packages/vconsole-helper/global.d.ts | 5 + packages/vconsole-helper/package.json | 26 +++ packages/vconsole-helper/rollup.config.js | 3 + packages/vconsole-helper/src/config.ts | 172 +++++++++++++++ packages/vconsole-helper/src/debug.ts | 52 +++++ packages/vconsole-helper/src/index.ts | 22 ++ packages/vconsole-helper/src/plugin/delay.ts | 57 +++++ packages/vconsole-helper/src/plugin/env.ts | 55 +++++ .../vconsole-helper/src/plugin/feedback.ts | 52 +++++ packages/vconsole-helper/src/plugin/msdk.ts | 28 +++ .../src/plugin/version-simple.ts | 47 ++++ .../vconsole-helper/src/plugin/version.ts | 207 ++++++++++++++++++ packages/vconsole-helper/src/toggle.ts | 81 +++++++ packages/vconsole-helper/src/types.ts | 5 + packages/vconsole-helper/src/v-console.ts | 64 ++++++ packages/vconsole-helper/tsconfig.json | 11 + .../vite-plugin-add-code-at-end/package.json | 2 +- .../src/add-code-at-end.ts | 3 +- .../vite-plugin-alias-for-library/README.md | 4 +- .../package.json | 4 +- .../src/alias-for-library.ts | 4 +- .../src/index.ts | 2 +- .../CHANGELOG.md | 13 ++ .../README.md | 43 ++++ .../package.json | 27 +++ .../rollup.config.js | 3 + .../src/analyze-bundle-file-size.ts | 112 ++++++++++ .../src/index.ts | 1 + .../tsconfig.json | 10 + packages/vite-plugin-chunk-split/package.json | 4 +- .../vite-plugin-cross-game-style/package.json | 2 +- .../src/cross-game-style.ts | 3 +- .../vite-plugin-cross-platform/package.json | 2 +- .../src/cross-platform.ts | 3 +- .../vite-plugin-dispatch-script/package.json | 6 +- .../vite-plugin-dispatch-vue/CHANGELOG.md | 23 ++ .../vite-plugin-dispatch-vue/package.json | 6 +- .../src/dispatch-vue.ts | 11 +- .../vite-plugin-dispatch-vue/src/helper.ts | 21 +- packages/vite-plugin-fix-uni-dir/package.json | 2 +- .../src/fix-uni-dir.ts | 7 +- packages/vite-plugin-free-pages/package.json | 4 +- .../src/vite-plugin-free-pages.ts | 5 +- .../vite-plugin-gen-mp-qq-app-id/package.json | 4 +- .../src/gen-mp-qq-app-id.ts | 5 +- packages/vite-plugin-gen-version/CHANGELOG.md | 10 + packages/vite-plugin-gen-version/package.json | 4 +- packages/vite-plugin-gen-version/src/mp.ts | 5 +- packages/vite-plugin-gen-version/src/web.ts | 2 +- .../package.json | 2 +- .../src/global-this-polyfill.ts | 7 +- packages/vite-plugin-guru-pages/package.json | 4 +- .../src/vite-plugin-guru-pages.ts | 5 +- packages/vite-plugin-ifdef/package.json | 4 +- packages/vite-plugin-ifdef/src/ifdef.ts | 5 +- .../package.json | 6 +- .../vite-plugin-legacy-polyfill/CHANGELOG.md | 6 + .../vite-plugin-legacy-polyfill/README.md | 54 +++++ .../vite-plugin-legacy-polyfill/package.json | 26 +++ .../rollup.config.js | 3 + .../vite-plugin-legacy-polyfill/src/index.ts | 2 + .../vite-plugin-legacy-polyfill/src/types.ts | 3 + .../src/vite-plugin-legacy-polyfill.ts | 86 ++++++++ .../vite-plugin-legacy-polyfill/tsconfig.json | 10 + packages/vite-plugin-rem-to-rpx/package.json | 4 +- .../vite-plugin-rem-to-rpx/src/rem-to-rpx.ts | 6 +- .../vite-plugin-remove-use-rem/package.json | 2 +- .../package.json | 2 +- .../src/remove-vue-directive.ts | 5 +- .../vite-plugin-replace-keyword/CHANGELOG.md | 6 + .../vite-plugin-replace-keyword/README.md | 45 ++++ .../vite-plugin-replace-keyword/package.json | 26 +++ .../rollup.config.js | 3 + .../vite-plugin-replace-keyword/src/index.ts | 2 + .../src/replace-keyword.ts | 34 +++ .../vite-plugin-replace-keyword/src/types.ts | 10 + .../vite-plugin-replace-keyword/tsconfig.json | 10 + .../package.json | 2 +- .../src/replace-require-dynamic.ts | 5 +- .../package.json | 6 +- .../src/support-default-route.ts | 3 +- .../package.json | 6 +- .../src/support-named-route.ts | 3 +- .../vite-plugin-transform-v-lazy/package.json | 2 +- .../src/transform-v-lazy.ts | 6 +- .../package.json | 2 +- .../package.json | 4 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- packages/webpack-loader-ifdef/package.json | 2 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- packages/webpack-loader-publish/package.json | 6 +- .../webpack-loader-remove-scoped/package.json | 2 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 4 +- packages/webpack-loader-v-lazy/package.json | 2 +- .../webpack-loader-vue-directive/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../webpack-plugin-analyze-deps/package.json | 4 +- .../package.json | 2 +- packages/webpack-plugin-copy-dir/package.json | 2 +- .../package.json | 2 +- .../CHANGELOG.md | 24 ++ .../package.json | 9 +- .../src/helper.ts | 3 +- .../webpack-plugin-dispatch-vue/CHANGELOG.md | 27 +++ .../webpack-plugin-dispatch-vue/package.json | 9 +- .../src/analyze-component.ts | 3 +- .../webpack-plugin-dispatch-vue/src/helper.ts | 3 +- .../package.json | 4 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 4 +- .../webpack-plugin-gen-version/CHANGELOG.md | 20 ++ .../webpack-plugin-gen-version/package.json | 8 +- .../package.json | 2 +- .../package.json | 2 +- .../webpack-plugin-insert-script/package.json | 2 +- .../package.json | 2 +- .../webpack-plugin-modify-html/package.json | 4 +- .../webpack-plugin-rem-to-rpx/package.json | 4 +- .../package.json | 2 +- .../package.json | 4 +- .../package.json | 2 +- packages/webpack-plugin-tailwind/README.md | 2 +- .../package.json | 2 +- script/build/rollup.config-runtime.js | 86 ++++++++ script/docs/gen-docs-monorepo.js | 6 + 199 files changed, 3086 insertions(+), 317 deletions(-) create mode 100644 docs/changelog/vconsole-helper.md create mode 100644 docs/changelog/vite-plugin-analyze-bundle-file-size.md create mode 100644 docs/changelog/vite-plugin-legacy-polyfill.md create mode 100644 docs/changelog/vite-plugin-replace-keyword.md create mode 100644 docs/zh/vconsole-helper.md create mode 100644 docs/zh/vite-plugin-analyze-bundle-file-size.md create mode 100644 docs/zh/vite-plugin-legacy-polyfill.md create mode 100644 docs/zh/vite-plugin-replace-keyword.md create mode 100644 packages/plugin-light-shared-vue2/src/uni-cli-shared.ts create mode 100644 packages/plugin-light-shared/src/platform.ts delete mode 100644 packages/project-config-uni-vite/.npmrc create mode 100644 packages/project-config-uni-vite/src/chunk-split.ts create mode 100644 packages/vconsole-helper/CHANGELOG.md create mode 100644 packages/vconsole-helper/README.md create mode 100644 packages/vconsole-helper/global.d.ts create mode 100644 packages/vconsole-helper/package.json create mode 100644 packages/vconsole-helper/rollup.config.js create mode 100644 packages/vconsole-helper/src/config.ts create mode 100644 packages/vconsole-helper/src/debug.ts create mode 100644 packages/vconsole-helper/src/index.ts create mode 100644 packages/vconsole-helper/src/plugin/delay.ts create mode 100644 packages/vconsole-helper/src/plugin/env.ts create mode 100644 packages/vconsole-helper/src/plugin/feedback.ts create mode 100644 packages/vconsole-helper/src/plugin/msdk.ts create mode 100644 packages/vconsole-helper/src/plugin/version-simple.ts create mode 100644 packages/vconsole-helper/src/plugin/version.ts create mode 100644 packages/vconsole-helper/src/toggle.ts create mode 100644 packages/vconsole-helper/src/types.ts create mode 100644 packages/vconsole-helper/src/v-console.ts create mode 100644 packages/vconsole-helper/tsconfig.json create mode 100644 packages/vite-plugin-analyze-bundle-file-size/CHANGELOG.md create mode 100644 packages/vite-plugin-analyze-bundle-file-size/README.md create mode 100644 packages/vite-plugin-analyze-bundle-file-size/package.json create mode 100644 packages/vite-plugin-analyze-bundle-file-size/rollup.config.js create mode 100644 packages/vite-plugin-analyze-bundle-file-size/src/analyze-bundle-file-size.ts create mode 100644 packages/vite-plugin-analyze-bundle-file-size/src/index.ts create mode 100644 packages/vite-plugin-analyze-bundle-file-size/tsconfig.json create mode 100644 packages/vite-plugin-legacy-polyfill/CHANGELOG.md create mode 100644 packages/vite-plugin-legacy-polyfill/README.md create mode 100644 packages/vite-plugin-legacy-polyfill/package.json create mode 100644 packages/vite-plugin-legacy-polyfill/rollup.config.js create mode 100644 packages/vite-plugin-legacy-polyfill/src/index.ts create mode 100644 packages/vite-plugin-legacy-polyfill/src/types.ts create mode 100644 packages/vite-plugin-legacy-polyfill/src/vite-plugin-legacy-polyfill.ts create mode 100644 packages/vite-plugin-legacy-polyfill/tsconfig.json create mode 100644 packages/vite-plugin-replace-keyword/CHANGELOG.md create mode 100644 packages/vite-plugin-replace-keyword/README.md create mode 100644 packages/vite-plugin-replace-keyword/package.json create mode 100644 packages/vite-plugin-replace-keyword/rollup.config.js create mode 100644 packages/vite-plugin-replace-keyword/src/index.ts create mode 100644 packages/vite-plugin-replace-keyword/src/replace-keyword.ts create mode 100644 packages/vite-plugin-replace-keyword/src/types.ts create mode 100644 packages/vite-plugin-replace-keyword/tsconfig.json create mode 100644 script/build/rollup.config-runtime.js diff --git a/README.md b/README.md index af76903..661c76f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ + ## Plugin Light -`Plugin Light` 是一个丰富、易用的工具集。包含一些 `Webpack` 相关插件,比如 +`Plugin Light` 是一个丰富、易用的工具集。包含一些 `Webpack` 相关插件(25+),比如 - [依赖分析 (webpack-plugin-analyze-deps)](./packages/webpack-plugin-analyze-deps/) - [脚本分发 (webpack-plugin-dispatch-script)](./packages/webpack-plugin-dispatch-script/) @@ -14,7 +15,7 @@ - ... -以及一些 `Webpack Loader` +以及一些 `Webpack Loader`(20+) - [自定义`ifdef` (webpack-loader-ifdef)](./packages/webpack-loader-ifdef/) - [插入全局组件 (webpack-loader-insert-global-comp)](./packages/webpack-loader-insert-global-comp/) @@ -26,7 +27,7 @@ - ... -一些 `Vite Plugin` +一些 `Vite Plugin`(23+) - [文件后增加代码 (vite-plugin-add-code-at-end)](./packages/vite-plugin-add-code-at-end/) - [三方库别名处理 (vite-plugin-alias-for-library)](./packages/vite-plugin-alias-for-library/) diff --git a/docs/.vuepress/sidebar-changelog.json b/docs/.vuepress/sidebar-changelog.json index 6a92e55..58bc166 100644 --- a/docs/.vuepress/sidebar-changelog.json +++ b/docs/.vuepress/sidebar-changelog.json @@ -44,6 +44,10 @@ "title": "uni-read-pages-vite", "path": "/changelog/uni-read-pages-vite.md" }, + { + "title": "vconsole-helper", + "path": "/changelog/vconsole-helper.md" + }, { "title": "vite-plugin-add-code-at-end", "path": "/changelog/vite-plugin-add-code-at-end.md" @@ -52,6 +56,10 @@ "title": "vite-plugin-alias-for-library", "path": "/changelog/vite-plugin-alias-for-library.md" }, + { + "title": "vite-plugin-analyze-bundle-file-size", + "path": "/changelog/vite-plugin-analyze-bundle-file-size.md" + }, { "title": "vite-plugin-chunk-split", "path": "/changelog/vite-plugin-chunk-split.md" @@ -96,10 +104,18 @@ "title": "vite-plugin-insert-global-comp", "path": "/changelog/vite-plugin-insert-global-comp.md" }, + { + "title": "vite-plugin-legacy-polyfill", + "path": "/changelog/vite-plugin-legacy-polyfill.md" + }, { "title": "vite-plugin-rem-to-rpx", "path": "/changelog/vite-plugin-rem-to-rpx.md" }, + { + "title": "vite-plugin-replace-keyword", + "path": "/changelog/vite-plugin-replace-keyword.md" + }, { "title": "vite-plugin-replace-require-dynamic", "path": "/changelog/vite-plugin-replace-require-dynamic.md" diff --git a/docs/.vuepress/sidebar.json b/docs/.vuepress/sidebar.json index 035540c..31517bb 100644 --- a/docs/.vuepress/sidebar.json +++ b/docs/.vuepress/sidebar.json @@ -156,6 +156,10 @@ "title": "三方库别名处理", "path": "/zh/vite-plugin-alias-for-library.md" }, + { + "title": "产物文件大小分析", + "path": "/zh/vite-plugin-analyze-bundle-file-size.md" + }, { "title": "vite-plugin-chunk-split", "path": "/zh/vite-plugin-chunk-split.md" @@ -200,10 +204,18 @@ "title": "全局组件注入", "path": "/zh/vite-plugin-insert-global-comp.md" }, + { + "title": "修复 vitejs/plugin-legacy 不支持 CDN", + "path": "/zh/vite-plugin-legacy-polyfill.md" + }, { "title": "Rem 转换", "path": "/zh/vite-plugin-rem-to-rpx.md" }, + { + "title": "替换关键词", + "path": "/zh/vite-plugin-replace-keyword.md" + }, { "title": "动态导入组件语法替换", "path": "/zh/vite-plugin-replace-require-dynamic.md" @@ -283,6 +295,16 @@ "path": "/zh/uni-read-pages-vite.md" } ] + }, + { + "title": "运行时", + "collapsable": false, + "children": [ + { + "title": "VConsole 工具", + "path": "/zh/vconsole-helper.md" + } + ] } ] } \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index da85020..8d806b8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,7 @@ - + ## Plugin Light -`Plugin Light` 是一个丰富、易用的工具集。包含一些 `Webpack` 相关插件,比如 +`Plugin Light` 是一个丰富、易用的工具集。包含一些 `Webpack` 相关插件(25+),比如 - [依赖分析 (webpack-plugin-analyze-deps)](./zh/webpack-plugin-analyze-deps/) - [脚本分发 (webpack-plugin-dispatch-script)](./zh/webpack-plugin-dispatch-script/) @@ -14,7 +14,7 @@ - ... -以及一些 `Webpack Loader` +以及一些 `Webpack Loader`(20+) - [自定义`ifdef` (webpack-loader-ifdef)](./zh/webpack-loader-ifdef/) - [插入全局组件 (webpack-loader-insert-global-comp)](./zh/webpack-loader-insert-global-comp/) @@ -26,7 +26,7 @@ - ... -一些 `Vite Plugin` +一些 `Vite Plugin`(23+) - [文件后增加代码 (vite-plugin-add-code-at-end)](./zh/vite-plugin-add-code-at-end/) - [三方库别名处理 (vite-plugin-alias-for-library)](./zh/vite-plugin-alias-for-library/) @@ -127,4 +127,3 @@ module.export = { 3. `sync-repo` 功能已经废弃。 4. `stylelint-plugin/no-useless-css` 插件已经废弃。 - diff --git a/docs/changelog/plugin-light-shared-vue2.md b/docs/changelog/plugin-light-shared-vue2.md index f394fb2..58cfeb2 100644 --- a/docs/changelog/plugin-light-shared-vue2.md +++ b/docs/changelog/plugin-light-shared-vue2.md @@ -1,5 +1,14 @@ # plugin-light-shared-vue2 +## 0.0.8 (2024-12-14) + +* feat(uni-cli-shared): 分离vue2版本的uni-cli-shared ([cde37ee](https://github.com/novlan1/plugin-light/commits/cde37ee)) +* chore: 优化版本号 ([bf5a4cb](https://github.com/novlan1/plugin-light/commits/bf5a4cb)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) + + + ## 0.0.7 (2024-11-24) * chore: add meta in pkg.json ([3f6088c](https://github.com/novlan1/plugin-light/commits/3f6088c)) diff --git a/docs/changelog/plugin-light-shared.md b/docs/changelog/plugin-light-shared.md index bad1d30..3c34cbd 100644 --- a/docs/changelog/plugin-light-shared.md +++ b/docs/changelog/plugin-light-shared.md @@ -1,5 +1,32 @@ # plugin-light-shared +## 0.0.18 (2024-12-24) + +* feat(bundle): add analyze-bundle-file-size ([8f5a04f](https://github.com/novlan1/plugin-light/commits/8f5a04f)) + + + +## 0.0.17 (2024-12-16) + +* feat(gen-version): remove quote ([ec2a6cb](https://github.com/novlan1/plugin-light/commits/ec2a6cb)) + + + +## 0.0.16 (2024-12-14) + +* feat(uni-cli-shared): 分离vue2版本的uni-cli-shared ([cde37ee](https://github.com/novlan1/plugin-light/commits/cde37ee)) + + + +## 0.0.15 (2024-12-14) + +* feat(cdn-map): 统一使用shared中的cdnMap ([7bac1bb](https://github.com/novlan1/plugin-light/commits/7bac1bb)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) + + + ## 0.0.14 (2024-12-05) * feat(shared): add findNodeModulesFile ([232a7df](https://github.com/novlan1/plugin-light/commits/232a7df)) diff --git a/docs/changelog/project-config-uni-vite.md b/docs/changelog/project-config-uni-vite.md index b11ae1e..944bcdd 100644 --- a/docs/changelog/project-config-uni-vite.md +++ b/docs/changelog/project-config-uni-vite.md @@ -1,5 +1,84 @@ # project-config-uni-vite +## 0.0.32 (2025-01-07) + +* feat(legacy-polyfill): add vite-plugin-legacy-polyfill ([2c851f7](https://github.com/novlan1/plugin-light/commits/2c851f7)) +* feat(uni-vite): add vite-plugin-legacy-polyfill ([2383514](https://github.com/novlan1/plugin-light/commits/2383514)) + + + +## 0.0.31 (2025-01-06) + +* feat(uni-vite): add useESBuildPlugin ([8bee879](https://github.com/novlan1/plugin-light/commits/8bee879)) + + + +## 0.0.30 (2025-01-06) + +* feat(uni-vite): add legacy ([01c51f3](https://github.com/novlan1/plugin-light/commits/01c51f3)) +* docs: update docs ([7a2e888](https://github.com/novlan1/plugin-light/commits/7a2e888)) + + + +## 0.0.29 (2024-12-25) + +* feat(project-config-uni-vite): update pmd-npm name ([405b787](https://github.com/novlan1/plugin-light/commits/405b787)) +* refactor: use t-comm generateCSVData ([dd92800](https://github.com/novlan1/plugin-light/commits/dd92800)) + + + +## 0.0.28 (2024-12-25) + +* feat(bundle): add analyze-bundle-file-size ([8f5a04f](https://github.com/novlan1/plugin-light/commits/8f5a04f)) +* feat(project-config-uni-vite): add analyze-bundle-file-size ([2ffe713](https://github.com/novlan1/plugin-light/commits/2ffe713)) +* docs: update docs ([e9a9f9c](https://github.com/novlan1/plugin-light/commits/e9a9f9c)) +* chore: update docs ([4d4335e](https://github.com/novlan1/plugin-light/commits/4d4335e)) + + + +## 0.0.27 (2024-12-16) + +* update deps + + +## 0.0.26 (2024-12-15) + +* fix(project-config-uni-vite): fix cssConfig error ([a4c0d78](https://github.com/novlan1/plugin-light/commits/a4c0d78)) + + + +## 0.0.25 (2024-12-15) + +* feat(project-config-uni-vite): hide warning ([de854b4](https://github.com/novlan1/plugin-light/commits/de854b4)) + + + +## 0.0.24 (2024-12-15) + +* feat(project-config-uni-vite): add css options ([4f0ead2](https://github.com/novlan1/plugin-light/commits/4f0ead2)) +* docs: update docs ([d48e2ce](https://github.com/novlan1/plugin-light/commits/d48e2ce)) + + + + +## 0.0.22 (2024-12-14) + +* chore(project-config-uni-vite): update types ([7305bf3](https://github.com/novlan1/plugin-light/commits/7305bf3)) + + + +## 0.0.21 (2024-12-14) + +* feat(cdn-map): 统一使用shared中的cdnMap ([7bac1bb](https://github.com/novlan1/plugin-light/commits/7bac1bb)) +* feat(project-config-uni-vite): add useChunkSplit ([484b1eb](https://github.com/novlan1/plugin-light/commits/484b1eb)) +* chore: lint ([9deff90](https://github.com/novlan1/plugin-light/commits/9deff90)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update docs ([f8f5a1b](https://github.com/novlan1/plugin-light/commits/f8f5a1b)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) + + + ## 0.0.20 (2024-12-06) * feat(project-config-uni-vite): remove console and debug ([6beaec5](https://github.com/novlan1/plugin-light/commits/6beaec5)) diff --git a/docs/changelog/project-config-uni-vue.md b/docs/changelog/project-config-uni-vue.md index 4af922a..1636ae6 100644 --- a/docs/changelog/project-config-uni-vue.md +++ b/docs/changelog/project-config-uni-vue.md @@ -1,5 +1,17 @@ # project-config-uni-vue +## 0.0.4 (2024-12-16) + +* feat(cdn-map): 统一使用shared中的cdnMap ([7bac1bb](https://github.com/novlan1/plugin-light/commits/7bac1bb)) +* chore: 优化版本号 ([bf5a4cb](https://github.com/novlan1/plugin-light/commits/bf5a4cb)) +* chore: 增加导出types ([58edd0b](https://github.com/novlan1/plugin-light/commits/58edd0b)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* chore: update t-comm ([72ee5c2](https://github.com/novlan1/plugin-light/commits/72ee5c2)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) + + + ## 0.0.3 (2024-11-19) * feat(project-config-uni-vue): 支持打包产物位置自定义 ([d7be14c](https://github.com/novlan1/plugin-light/commits/d7be14c)) diff --git a/docs/changelog/vconsole-helper.md b/docs/changelog/vconsole-helper.md new file mode 100644 index 0000000..f9cbea5 --- /dev/null +++ b/docs/changelog/vconsole-helper.md @@ -0,0 +1,21 @@ +# vconsole-helper + +## 0.0.4 (2025-01-13) + +* feat(vconsole): 优化vconsole ([373e119](https://github.com/novlan1/plugin-light/commits/373e119)) + + + +## 0.0.3 (2025-01-13) + +* docs: update docs ([0fe3c0e](https://github.com/novlan1/plugin-light/commits/0fe3c0e)) + + + +## 0.0.2 (2025-01-13) + +* feat(vconsole-helper): add vconsole-helper ([3b65f43](https://github.com/novlan1/plugin-light/commits/3b65f43)) +* feat(vconsole): 优化vsonsole ([25a9084](https://github.com/novlan1/plugin-light/commits/25a9084)) + + + diff --git a/docs/changelog/vite-plugin-analyze-bundle-file-size.md b/docs/changelog/vite-plugin-analyze-bundle-file-size.md new file mode 100644 index 0000000..8dcbbe9 --- /dev/null +++ b/docs/changelog/vite-plugin-analyze-bundle-file-size.md @@ -0,0 +1,15 @@ +# vite-plugin-analyze-bundle-file-size + +## 0.0.3 (2024-12-25) + +* feat(analyze): 优化输出文件名称 ([aa195bd](https://github.com/novlan1/plugin-light/commits/aa195bd)) +* docs: update docs ([1a1238a](https://github.com/novlan1/plugin-light/commits/1a1238a)) + + + +## 0.0.2 (2024-12-24) + +* feat(bundle): add analyze-bundle-file-size ([8f5a04f](https://github.com/novlan1/plugin-light/commits/8f5a04f)) + + + diff --git a/docs/changelog/vite-plugin-dispatch-vue.md b/docs/changelog/vite-plugin-dispatch-vue.md index b76a1ad..e6d5cb5 100644 --- a/docs/changelog/vite-plugin-dispatch-vue.md +++ b/docs/changelog/vite-plugin-dispatch-vue.md @@ -1,5 +1,28 @@ # vite-plugin-dispatch-vue +## 0.0.15 (2024-12-27) + +* feat(dispatch-vue): 支持windows ([a8d2a38](https://github.com/novlan1/plugin-light/commits/a8d2a38)) + + + +## 0.0.14 (2024-12-25) + +* feat(dispatch-vue): support windows ([4ee911e](https://github.com/novlan1/plugin-light/commits/4ee911e)) +* refactor: use t-comm generateCSVData ([dd92800](https://github.com/novlan1/plugin-light/commits/dd92800)) + + + +## 0.0.13 (2024-12-24) + +* feat(bundle): add analyze-bundle-file-size ([8f5a04f](https://github.com/novlan1/plugin-light/commits/8f5a04f)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* chore: update t-comm ([72ee5c2](https://github.com/novlan1/plugin-light/commits/72ee5c2)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) + + + ## 0.0.12 (2024-11-25) * feat(dispatch): 优化分发 ([3a0a896](https://github.com/novlan1/plugin-light/commits/3a0a896)) diff --git a/docs/changelog/vite-plugin-gen-version.md b/docs/changelog/vite-plugin-gen-version.md index b428dbe..1db4da9 100644 --- a/docs/changelog/vite-plugin-gen-version.md +++ b/docs/changelog/vite-plugin-gen-version.md @@ -1,5 +1,15 @@ # vite-plugin-gen-version +## 0.0.9 (2024-12-16) + +* chore: type Plugin type for vite-plugin ([ca2580c](https://github.com/novlan1/plugin-light/commits/ca2580c)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) +* feat(vite-plugin-insert-global-compo): 优化插件 ([3e52249](https://github.com/novlan1/plugin-light/commits/3e52249)) +* feat(vite-plugin): add insert-global-comp ([06f39d9](https://github.com/novlan1/plugin-light/commits/06f39d9)) + + + ## 0.0.8 (2024-11-25) * feat(gen-version): 生成sourcemap ([6f5f14c](https://github.com/novlan1/plugin-light/commits/6f5f14c)) diff --git a/docs/changelog/vite-plugin-legacy-polyfill.md b/docs/changelog/vite-plugin-legacy-polyfill.md new file mode 100644 index 0000000..8f6ab48 --- /dev/null +++ b/docs/changelog/vite-plugin-legacy-polyfill.md @@ -0,0 +1,8 @@ +# vite-plugin-legacy-polyfill + +## 0.0.2 (2025-01-07) + +* feat(legacy-polyfill): add vite-plugin-legacy-polyfill ([2c851f7](https://github.com/novlan1/plugin-light/commits/2c851f7)) + + + diff --git a/docs/changelog/vite-plugin-replace-keyword.md b/docs/changelog/vite-plugin-replace-keyword.md new file mode 100644 index 0000000..32db2fe --- /dev/null +++ b/docs/changelog/vite-plugin-replace-keyword.md @@ -0,0 +1,8 @@ +# vite-plugin-replace-keyword + +## 0.0.2 (2024-12-14) + +* feat(vite-plugin-replace-keyword): add vite-plugin-replace-keyword ([8285303](https://github.com/novlan1/plugin-light/commits/8285303)) + + + diff --git a/docs/changelog/webpack-plugin-dispatch-script.md b/docs/changelog/webpack-plugin-dispatch-script.md index 0055753..3e96930 100644 --- a/docs/changelog/webpack-plugin-dispatch-script.md +++ b/docs/changelog/webpack-plugin-dispatch-script.md @@ -1,5 +1,29 @@ # webpack-plugin-dispatch-script +## 0.0.6 (2024-12-14) + +* feat(uni-cli-shared): 分离vue2版本的uni-cli-shared ([cde37ee](https://github.com/novlan1/plugin-light/commits/cde37ee)) +* chore: 修改引用路径,path => node:path, fs => node:fs ([79784c6](https://github.com/novlan1/plugin-light/commits/79784c6)) +* chore: 优化版本号 ([bf5a4cb](https://github.com/novlan1/plugin-light/commits/bf5a4cb)) +* chore: add meta in pkg.json ([3f6088c](https://github.com/novlan1/plugin-light/commits/3f6088c)) +* chore: add release script ([defe6af](https://github.com/novlan1/plugin-light/commits/defe6af)) +* chore: update deps to latest ([455918d](https://github.com/novlan1/plugin-light/commits/455918d)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update docs ([1972659](https://github.com/novlan1/plugin-light/commits/1972659)) +* chore: update name ([02b2100](https://github.com/novlan1/plugin-light/commits/02b2100)) +* chore: update plugin-light-shared ([08a9790](https://github.com/novlan1/plugin-light/commits/08a9790)) +* chore: update plugin-light-shared to 0.0.12 ([4d33550](https://github.com/novlan1/plugin-light/commits/4d33550)) +* chore: update release.sh ([d59a9c0](https://github.com/novlan1/plugin-light/commits/d59a9c0)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* chore: update t-comm ([72ee5c2](https://github.com/novlan1/plugin-light/commits/72ee5c2)) +* chore: update tsconfig.json ([7d20e75](https://github.com/novlan1/plugin-light/commits/7d20e75)) +* docs: move docs position ([1937e17](https://github.com/novlan1/plugin-light/commits/1937e17)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) +* docs: update docs ([a7f894e](https://github.com/novlan1/plugin-light/commits/a7f894e)) +* test: update packages tests ([6276643](https://github.com/novlan1/plugin-light/commits/6276643)) + + + ## 0.0.5 (2024-09-18) * chore: update project-config ([af4ff17](https://github.com/novlan1/plugin-light/commits/af4ff17)) diff --git a/docs/changelog/webpack-plugin-dispatch-vue.md b/docs/changelog/webpack-plugin-dispatch-vue.md index bab2049..9a04374 100644 --- a/docs/changelog/webpack-plugin-dispatch-vue.md +++ b/docs/changelog/webpack-plugin-dispatch-vue.md @@ -1,5 +1,32 @@ # webpack-plugin-dispatch-vue +## 0.0.6 (2024-12-16) + +* chore: update deps + + +## 0.0.5 (2024-12-14) + +* feat(uni-cli-shared): 分离vue2版本的uni-cli-shared ([cde37ee](https://github.com/novlan1/plugin-light/commits/cde37ee)) +* chore: 修改引用路径,path => node:path, fs => node:fs ([79784c6](https://github.com/novlan1/plugin-light/commits/79784c6)) +* chore: 优化版本号 ([bf5a4cb](https://github.com/novlan1/plugin-light/commits/bf5a4cb)) +* chore: add meta in pkg.json ([3f6088c](https://github.com/novlan1/plugin-light/commits/3f6088c)) +* chore: add release script ([defe6af](https://github.com/novlan1/plugin-light/commits/defe6af)) +* chore: update deps to latest ([455918d](https://github.com/novlan1/plugin-light/commits/455918d)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update docs ([1972659](https://github.com/novlan1/plugin-light/commits/1972659)) +* chore: update name ([02b2100](https://github.com/novlan1/plugin-light/commits/02b2100)) +* chore: update release.sh ([d59a9c0](https://github.com/novlan1/plugin-light/commits/d59a9c0)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* chore: update t-comm ([72ee5c2](https://github.com/novlan1/plugin-light/commits/72ee5c2)) +* chore: update tsconfig.json ([7d20e75](https://github.com/novlan1/plugin-light/commits/7d20e75)) +* docs: move docs position ([1937e17](https://github.com/novlan1/plugin-light/commits/1937e17)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) +* refactor(webpack-dispatch-vue): use t-comm funcs ([cfecb64](https://github.com/novlan1/plugin-light/commits/cfecb64)) +* test: update packages tests ([6276643](https://github.com/novlan1/plugin-light/commits/6276643)) + + + ## 0.0.4 (2024-09-18) * chore: update project-config ([af4ff17](https://github.com/novlan1/plugin-light/commits/af4ff17)) diff --git a/docs/changelog/webpack-plugin-gen-version.md b/docs/changelog/webpack-plugin-gen-version.md index d006949..d01adf4 100644 --- a/docs/changelog/webpack-plugin-gen-version.md +++ b/docs/changelog/webpack-plugin-gen-version.md @@ -1,5 +1,25 @@ # webpack-plugin-gen-version +## 0.0.6 (2024-12-16) + +* chore: 优化版本号 ([bf5a4cb](https://github.com/novlan1/plugin-light/commits/bf5a4cb)) +* chore: add meta in pkg.json ([3f6088c](https://github.com/novlan1/plugin-light/commits/3f6088c)) +* chore: add release script ([defe6af](https://github.com/novlan1/plugin-light/commits/defe6af)) +* chore: update deps to latest ([455918d](https://github.com/novlan1/plugin-light/commits/455918d)) +* chore: update docs ([43dbc9d](https://github.com/novlan1/plugin-light/commits/43dbc9d)) +* chore: update docs ([1972659](https://github.com/novlan1/plugin-light/commits/1972659)) +* chore: update name ([02b2100](https://github.com/novlan1/plugin-light/commits/02b2100)) +* chore: update plugin-light-shared ([08a9790](https://github.com/novlan1/plugin-light/commits/08a9790)) +* chore: update plugin-light-shared to 0.0.12 ([4d33550](https://github.com/novlan1/plugin-light/commits/4d33550)) +* chore: update t-comm ([4db6427](https://github.com/novlan1/plugin-light/commits/4db6427)) +* chore: update t-comm ([72ee5c2](https://github.com/novlan1/plugin-light/commits/72ee5c2)) +* chore: update tsconfig.json ([7d20e75](https://github.com/novlan1/plugin-light/commits/7d20e75)) +* docs: move docs position ([1937e17](https://github.com/novlan1/plugin-light/commits/1937e17)) +* docs: update docs ([cc81245](https://github.com/novlan1/plugin-light/commits/cc81245)) +* test: update packages tests ([4897b59](https://github.com/novlan1/plugin-light/commits/4897b59)) + + + ## 0.0.5 (2024-09-18) * chore: update project-config ([af4ff17](https://github.com/novlan1/plugin-light/commits/af4ff17)) diff --git a/docs/zh/project-config-uni-vite.md b/docs/zh/project-config-uni-vite.md index 43c1560..33a47a1 100644 --- a/docs/zh/project-config-uni-vite.md +++ b/docs/zh/project-config-uni-vite.md @@ -26,24 +26,69 @@ export default defineConfig(({ mode }) => { ### 参数 ```ts -import type { Plugin } from 'vite'; +import type { Plugin, ServerOptions, CommonServerOptions, BuildOptions } from 'vite'; +import type { Server } from 'node:https'; +import tailwindcss from 'tailwindcss'; +import type { UniTailwindPluginUserOptions } from '@uni-helper/vite-plugin-uni-tailwind'; +import type { IRemoveVueDirectionOptions } from '@plugin-light/vite-plugin-remove-vue-directive'; +import type { ICrossGameStyleOptions } from '@plugin-light/vite-plugin-cross-game-style'; +import type { Options as TransformWebTagOptions } from '@plugin-light/postcss-plugin-transform-web-tag'; +import type { Options as LegacyOptions } from '@vitejs/plugin-legacy'; +import type { Options as ESBuildOptions } from 'rollup-plugin-esbuild'; export interface IUniViteConfigOptions { mode: string; uni: any; // 端口,传递给 server.port - port?: number; + port?: CommonServerOptions['port']; // https 配置,传递给 server.https - https?: Record; + https?: Server; // host 配置,传递给 server.host - host?: boolean; + host?: CommonServerOptions['host']; // 前置插件 prePlugins?: Array; // 后置插件 postPlugins?: Array; + + // 对应 optimizeDeps.include + optimizeDepsIncludes?: Array; + + removeVueDirectionOptions?: IRemoveVueDirectionOptions; + + hmr?: ServerOptions['hmr']; + + // 语法警报列表,比如 v-model,destroyed + warnList?: ICrossGameStyleOptions['warnList']; + + // transform-web-tag postcss插件 + transformWebTagOptions?: boolean | TransformWebTagOptions; + + // uniTailwind 插件 + uniTailwindOptions?: boolean | UniTailwindPluginUserOptions; + + // tailwindcss postcss插件 + tailwindcssOptions?: boolean | Parameters[0]; + + // 构建选项 + buildOptions?: BuildOptions; + + // 是否使用chunk-split + useChunkSplit?: boolean; + + // 是否使用 @vitejs/plugin-legacy + // 传递对象格式将作为插件参数 + useLegacy?: boolean | LegacyOptions; + + + // 传递给 uni 插件的参数 + uniOptions?: any; + + // 是否使用 rollup-plugin-esbuild + // 传递对象格式将作为插件参数 + useESBuildPlugin?: boolean | ESBuildOptions; } ``` @@ -89,6 +134,38 @@ require('@plugin-light/project-config-uni-vite/public-script/uni/fix-uni-dir'); require('@plugin-light/project-config-uni-vite/public-script/watch/watch-sass')(); ``` +### SCSS 警告说明 + +配置中屏蔽了 [import](https://sass-lang.com/documentation/breaking-changes/import/)、[legacy-js-api](https://sass-lang.com/documentation/breaking-changes/legacy-js-api/)、[mixed-decls](https://sass-lang.com/documentation/breaking-changes/mixed-decls/) 的相关警告信息。 + +原因如下: + +1. `uni-app` 会把 `uni.scss` 放到业务每个 `scss` 前面,所以 `@import` 改成 `@use` 后,会报错 `@use rules must be written before any other rules` + +2. `legacy-js-api` 问题,也是 `uni-app` 中使用了 `node-sass` 的 `renderSync` + +3. `mixed-decls` 问题,涉及到样式优先级问题,业务自己判断即可 + +### useChunkSplit 说明 + +设置 `useChunkSplit` 为 `true` 后,将会开启: + +1. 将 `aegis-v2`、`axios` 作为外链 +2. 将一些库单独拆包 + - `t-comm、press-ui、press-plus、 pmd-npm` => `pmd-pkg` + - `@dcloudio/uni-h5` => `uni-h5` + +仅在 H5 下有效。 + +### 低版本浏览器兼容 + +使用方式为,设置 `useLegacy` 为 `true`。 + +原理,使用了 [@vitejs/plugin-legacy](https://www.npmjs.com/package/@vitejs/plugin-legacy) 这个三方库,以及[修复了它不支持 `CDN` 的问题](./vite-plugin-legacy-polyfill.html)。 + +是否会影响 H5 在高版本浏览器的性能?基本不会,具体可自行搜索 [@vitejs/plugin-legacy](https://www.npmjs.com/package/@vitejs/plugin-legacy) 的原理。 + +如何判断当前项目是运行的的 `module` 产物,还是 `legacy` 产物?控制台打印 `window.__vite_is_modern_browser`,为 `true` 则表示运行的是 `module` 产物,否则为 `legacy` 产物。 ### 更新日志 diff --git a/docs/zh/vconsole-helper.md b/docs/zh/vconsole-helper.md new file mode 100644 index 0000000..6a25ec6 --- /dev/null +++ b/docs/zh/vconsole-helper.md @@ -0,0 +1,74 @@ +## VConsole 工具 + +运行时工具。可用于初始化 `VConsole`。 + +### 如何使用 + +安装 + +```bash +pnpm add vconsole-helper -D +``` + +`main.ts` 中: + +```ts +import { loadVConsole } from 'vconsole-helper'; + +loadVConsole(); + + +// options 会传递给 new window.VConsole +// plugins 会通过下面方式注册 vConsole.addPlugin(plugin()) +loadVConsole(options, plugins); +``` + +由于 `vconsole` 本身是调试工具,无需放到首包中,所以性能更佳的使用方法是使用外链: + +```ts +const VCONSOLE_HELPER_SCRIPT = 'https://image-1251917893.file.myqcloud.com/igame/npm/vconsole-helper/index%400.0.4.prod.js'; + +function innerLoadVConsole() { + if (!window.vConsoleHelper) return; + + const { genVConsole, V_CONSOLE_NO_DELAY = {} } = window.vConsoleHelper; + if (!genVConsole) return; + + const isShowVConsole = getUrlPara('vconsole') || ''; + const noDelay = sessionStorage.getItem(V_CONSOLE_NO_DELAY.KEY); + + + genVConsole({ + immediateShow: isShowVConsole === 'true' + || isTestEnv() + || noDelay === V_CONSOLE_NO_DELAY.VALUE, + hide: false, + asyncConfirmFunc: checkIsDevList, + vConsoleConfig: getConfig('vConsole'), + }); +} + + +export function loadVConsoleFromExternal() { + const isShowVConsole = getUrlPara('vconsole') || ''; + const isVConsoleDisable = !!getConfig('vConsole.disable'); + const hide = isShowVConsole === 'false' || !UserInfo.tipUid() || isVConsoleDisable; + + if (hide) return; + + loader(VCONSOLE_HELPER_SCRIPT, () => { + innerLoadVConsole(); + }); +} +``` + +优化效果,使用之后原文件大小减少`27.22KB`,`gzip`大小减少`10.78KB`。 + + + + + + +### 更新日志 + +[点此查看](../changelog/vconsole-helper.md) diff --git a/docs/zh/vite-plugin-alias-for-library.md b/docs/zh/vite-plugin-alias-for-library.md index bd7e170..6f67340 100644 --- a/docs/zh/vite-plugin-alias-for-library.md +++ b/docs/zh/vite-plugin-alias-for-library.md @@ -23,12 +23,12 @@ pnpm add @plugin-light/vite-plugin-alias-for-library -D ```ts import { defineConfig } from 'vite'; -import { aliasForLibrary } from '@plugin-light/vite-plugin-alias-for-library'; +import { aliasForLibraryVitePlugin } from '@plugin-light/vite-plugin-alias-for-library'; export default defineConfig({ plugins: [ - aliasForLibrary({ + aliasForLibraryVitePlugin({ list: [ 'press-ui', 'press-plus', diff --git a/docs/zh/vite-plugin-analyze-bundle-file-size.md b/docs/zh/vite-plugin-analyze-bundle-file-size.md new file mode 100644 index 0000000..7b61f16 --- /dev/null +++ b/docs/zh/vite-plugin-analyze-bundle-file-size.md @@ -0,0 +1,43 @@ +## 产物文件大小分析 + +小程序下,对组件的模板(`wxml/qml`等)、样式(`wxss/qss`等)、脚本文件(`.js`)大小的分析。 + +本插件解决的痛点是,**帮助开发者快速定位哪些组件问题最大、最亟需优化**。 + +插件会获取每个组件(包括页面)的上述三种产物的大小,以及样式与模板的体积比例、模板与脚本的体积比例,输出为 `json` 文件和 `csv` 文件,名称前缀均为`analyze-bundle-file-size`。 + +开发者可以据此进行分析,一般来说,**样式模板体积比(`cssHtmlRatio`)特别大的组件(基础组件除外),往往存在大量无用样式**。 + +可利用 `Excel` 中的自定义排序,对 `cssHtmlRatio` 进行降序,进而确定优化目标及优先级。 + + + + + +### 如何使用 + +安装 + +```bash +pnpm add @plugin-light/vite-plugin-analyze-bundle-file-size -D +``` + +在 `vite.config.ts` 中添加如下设置: + + +```ts +import { defineConfig } from 'vite'; +import { analyzeBundleFileSizeVitePlugin } from '@plugin-light/vite-plugin-analyze-bundle-file-size'; + + +export default defineConfig({ + plugins: [ + analyzeBundleFileSizeVitePlugin(), + ], +}); +``` + + +### 更新日志 + +[点此查看](../changelog/vite-plugin-analyze-bundle-file-size.md) diff --git a/docs/zh/vite-plugin-legacy-polyfill.md b/docs/zh/vite-plugin-legacy-polyfill.md new file mode 100644 index 0000000..c6d0721 --- /dev/null +++ b/docs/zh/vite-plugin-legacy-polyfill.md @@ -0,0 +1,54 @@ +## 修复 vitejs/plugin-legacy 不支持 CDN + +修复 `vitejs/plugin-legacy` 不支持 CDN 的问题。 + +### 如何使用 + +安装 + +```bash +pnpm add @plugin-light/vite-plugin-legacy-polyfill -D +``` + +在 `vite.config.ts` 中添加如下设置: + + +```ts +import { defineConfig } from 'vite'; +import { legacyPolyfillVitePlugin } from '@plugin-light/vite-plugin-legacy-polyfill'; + + +export default defineConfig({ + plugins: [ + legacyPolyfillVitePlugin({ + base: process.env.VUE_APP_PUBLICPATH, + }) + ], +}); +``` + +### 原理 + +替换 `index.html` 的脚本文件,核心替换列表如下: + +```ts +[ + { + from: '