feat: 依赖预构建

This commit is contained in:
wangfan 2025-01-18 21:40:18 +08:00
parent 10bab8b54c
commit 90226d70cb
5 changed files with 52 additions and 23 deletions

View File

@ -1,4 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/husky.sh"
npx --no-install commitlint --edit $1
. "${0%/*}/h"

View File

@ -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
View 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
View File

@ -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']
}
}

View File

@ -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.logterser打包慢但能去除console.log