|
@@ -1,6 +1,6 @@
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
|
-import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite";
|
|
|
+import { ConfigEnv, defineConfig, loadEnv, UserConfig } from "vite";
|
|
|
|
|
|
import AutoImport from "unplugin-auto-import/vite";
|
|
|
import Components from "unplugin-vue-components/vite";
|
|
@@ -14,13 +14,12 @@ import mockDevServerPlugin from "vite-plugin-mock-dev-server";
|
|
|
import UnoCSS from "unocss/vite";
|
|
|
import { resolve } from "path";
|
|
|
import {
|
|
|
- name,
|
|
|
- version,
|
|
|
- engines,
|
|
|
dependencies,
|
|
|
devDependencies,
|
|
|
+ engines,
|
|
|
+ name,
|
|
|
+ version,
|
|
|
} from "./package.json";
|
|
|
-import { directiveHooks } from "@vueuse/core";
|
|
|
|
|
|
/** 平台的名称、版本、运行所需的`node`版本、依赖、构建时间的类型提示 */
|
|
|
const __APP_INFO__ = {
|
|
@@ -199,7 +198,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|
|
},
|
|
|
// 构建配置
|
|
|
build: {
|
|
|
- chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告
|
|
|
+ chunkSizeWarningLimit: 4000, // 消除打包大小超过500kb警告
|
|
|
minify: "terser", // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
|
|
|
terserOptions: {
|
|
|
compress: {
|
|
@@ -213,9 +212,15 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|
|
},
|
|
|
rollupOptions: {
|
|
|
output: {
|
|
|
- // manualChunks: {
|
|
|
- // "vue-i18n": ["vue-i18n"],
|
|
|
- // },
|
|
|
+ manualChunks(id) {
|
|
|
+ if (id.includes("node_modules")) {
|
|
|
+ return id
|
|
|
+ .toString()
|
|
|
+ .split("node_modules/")[1]
|
|
|
+ .split("/")[0]
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ },
|
|
|
// 用于从入口点创建的块的打包输出格式[name]表示文件名,[hash]表示该文件内容hash值
|
|
|
entryFileNames: "js/[name].[hash].js",
|
|
|
// 用于命名代码拆分时创建的共享块的输出命名
|