mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
perf: 优化项目构建相关函数
This commit is contained in:
@@ -1,30 +1,13 @@
|
||||
import dayjs from "dayjs";
|
||||
import { resolve } from "path";
|
||||
import pkg from "./package.json";
|
||||
import { warpperEnv } from "./build";
|
||||
import { getPluginsList } from "./build/plugins";
|
||||
import { include, exclude } from "./build/optimize";
|
||||
import { type UserConfigExport, type ConfigEnv, loadEnv } from "vite";
|
||||
|
||||
/** 当前执行node命令时文件夹的地址(工作目录) */
|
||||
const root: string = process.cwd();
|
||||
|
||||
/** 路径查找 */
|
||||
const pathResolve = (dir: string): string => {
|
||||
return resolve(__dirname, ".", dir);
|
||||
};
|
||||
|
||||
/** 设置别名 */
|
||||
const alias: Record<string, string> = {
|
||||
"@": pathResolve("src"),
|
||||
"@build": pathResolve("build")
|
||||
};
|
||||
|
||||
const { dependencies, devDependencies, name, version } = pkg;
|
||||
const __APP_INFO__ = {
|
||||
pkg: { dependencies, devDependencies, name, version },
|
||||
lastBuildTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
|
||||
};
|
||||
import {
|
||||
root,
|
||||
alias,
|
||||
warpperEnv,
|
||||
pathResolve,
|
||||
__APP_INFO__
|
||||
} from "./build/utils";
|
||||
|
||||
export default ({ mode }: ConfigEnv): UserConfigExport => {
|
||||
const { VITE_CDN, VITE_PORT, VITE_COMPRESSION, VITE_PUBLIC_PATH } =
|
||||
@@ -61,7 +44,7 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
|
||||
chunkSizeWarningLimit: 4000,
|
||||
rollupOptions: {
|
||||
input: {
|
||||
index: pathResolve("index.html")
|
||||
index: pathResolve("./index.html", import.meta.url)
|
||||
},
|
||||
// 静态资源分类打包
|
||||
output: {
|
||||
|
||||
Reference in New Issue
Block a user