feat: 依赖预构建
This commit is contained in:
parent
10bab8b54c
commit
90226d70cb
@ -1,4 +1,2 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/husky.sh"
|
||||
|
||||
npx --no-install commitlint --edit $1
|
||||
. "${0%/*}/h"
|
||||
@ -1,4 +1,2 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname "$0")/husky.sh"
|
||||
|
||||
pnpm run lint:lint-staged
|
||||
. "${0%/*}/h"
|
||||
28
build/optimize.ts
Normal file
28
build/optimize.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* https://cn.vitejs.dev/config/dep-optimization-options#optimizedeps-exclude
|
||||
* 在 Vite 的配置文件 vite.config.ts 中,optimizeDeps 选项用于配置依赖优化,特别是预构建步骤,以提高开发和构建性能。
|
||||
* 这种情况尤其需要注意,当你禁止浏览器缓存时就必须将对应模块加载到依赖预构建,否则跳转时会频繁出现页面刷新的问题,因为它无法在浏览器缓存也没有在本地node_modules/.vite内缓存。
|
||||
* 如果使用的第三方库是全局引入,也就是src/main.ts文件里,那么它就会自动被vite缓存到node_modules/.vite,此时就不用将该第三方库做依赖预构建(添加到include内)。
|
||||
*/
|
||||
const include = [
|
||||
"vue-codemirror6",
|
||||
"qrcode",
|
||||
"jsbarcode",
|
||||
"vuedraggable",
|
||||
"@wangeditor/editor",
|
||||
"fingerprintjs2",
|
||||
"xgplayer",
|
||||
"print-js",
|
||||
"@codemirror/theme-one-dark",
|
||||
"@codemirror/lang-json",
|
||||
"@codemirror/lang-javascript",
|
||||
"@codemirror/lang-vue"
|
||||
];
|
||||
|
||||
/**
|
||||
* 在预构建中强制排除的依赖项
|
||||
* 如果你有某些依赖包不希望被预构建,可以使用 exclude 属性来排除它们。
|
||||
*/
|
||||
// const exclude = [];
|
||||
|
||||
export { include };
|
||||
30
src/components.d.ts
vendored
30
src/components.d.ts
vendored
@ -5,21 +5,21 @@
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
export {}
|
||||
|
||||
declare module "vue" {
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
BarcodeDraw: (typeof import("./components/barcode-draw/index.vue"))["default"];
|
||||
CodeView: (typeof import("./components/code-view/index.vue"))["default"];
|
||||
ExternalLinkPage: (typeof import("./components/external-link-page/index.vue"))["default"];
|
||||
FillPage: (typeof import("./components/fill-page/index.vue"))["default"];
|
||||
InternalLinkPage: (typeof import("./components/internal-link-page/index.vue"))["default"];
|
||||
LangProvider: (typeof import("./components/lang-provider/index.vue"))["default"];
|
||||
MainTransition: (typeof import("./components/main-transition/index.vue"))["default"];
|
||||
QrcodeDraw: (typeof import("./components/qrcode-draw/index.vue"))["default"];
|
||||
RouterLink: (typeof import("vue-router"))["RouterLink"];
|
||||
RouterView: (typeof import("vue-router"))["RouterView"];
|
||||
SelectIcon: (typeof import("./components/select-icon/index.vue"))["default"];
|
||||
SvgAndIcon: (typeof import("./components/svg-and-icon/index.vue"))["default"];
|
||||
SvgIcon: (typeof import("./components/svg-icon/index.vue"))["default"];
|
||||
VerifyCode: (typeof import("./components/verify-code/index.vue"))["default"];
|
||||
BarcodeDraw: typeof import('./components/barcode-draw/index.vue')['default']
|
||||
CodeView: typeof import('./components/code-view/index.vue')['default']
|
||||
ExternalLinkPage: typeof import('./components/external-link-page/index.vue')['default']
|
||||
FillPage: typeof import('./components/fill-page/index.vue')['default']
|
||||
InternalLinkPage: typeof import('./components/internal-link-page/index.vue')['default']
|
||||
LangProvider: typeof import('./components/lang-provider/index.vue')['default']
|
||||
MainTransition: typeof import('./components/main-transition/index.vue')['default']
|
||||
QrcodeDraw: typeof import('./components/qrcode-draw/index.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
SelectIcon: typeof import('./components/select-icon/index.vue')['default']
|
||||
SvgAndIcon: typeof import('./components/svg-and-icon/index.vue')['default']
|
||||
SvgIcon: typeof import('./components/svg-icon/index.vue')['default']
|
||||
VerifyCode: typeof import('./components/verify-code/index.vue')['default']
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { defineConfig, normalizePath, loadEnv } from "vite";
|
||||
import path from "path";
|
||||
import { resolve } from "path";
|
||||
import { include } from "./build/optimize";
|
||||
import postcssPresetEnv from "postcss-preset-env";
|
||||
import { createVitePlugins } from "./build/vite-plugin";
|
||||
const themePath = normalizePath(path.normalize("./src/style/global-theme.scss"));
|
||||
@ -47,6 +48,10 @@ export default defineConfig(({ mode }) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
// https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options
|
||||
optimizeDeps: {
|
||||
include
|
||||
},
|
||||
build: {
|
||||
outDir: "dist", // 指定打包路径,默认为项目根目录下的dist目录
|
||||
// minify: "esbuild", // esbuild打包更快但是不能去除console.log,terser打包慢但能去除console.log
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user