|
@@ -3,10 +3,10 @@ import { resolve } from 'path';
|
|
import { ConfigEnv, defineConfig, loadEnv } from 'vite';
|
|
import { ConfigEnv, defineConfig, loadEnv } from 'vite';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import compression from 'vite-plugin-compression';
|
|
import compression from 'vite-plugin-compression';
|
|
-import AutoImport from 'unplugin-auto-import/vite'
|
|
|
|
-import Components from 'unplugin-vue-components/vite'
|
|
|
|
-import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
|
|
-import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import'
|
|
|
|
|
|
+import AutoImport from 'unplugin-auto-import/vite';
|
|
|
|
+import Components from 'unplugin-vue-components/vite';
|
|
|
|
+import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
+import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import';
|
|
|
|
|
|
|
|
|
|
const pathResolve = (dir: string) => {
|
|
const pathResolve = (dir: string) => {
|
|
@@ -35,8 +35,8 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
{
|
|
{
|
|
'dayjs': [
|
|
'dayjs': [
|
|
// 默认导入
|
|
// 默认导入
|
|
- ['default', 'dayjs']
|
|
|
|
- ],
|
|
|
|
|
|
+ [ 'default', 'dayjs' ]
|
|
|
|
+ ]
|
|
// '/@/utils/useTableData': [
|
|
// '/@/utils/useTableData': [
|
|
// 'useTableData'
|
|
// 'useTableData'
|
|
// ],
|
|
// ],
|
|
@@ -46,10 +46,10 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
// '/@/utils/useResponse': [
|
|
// '/@/utils/useResponse': [
|
|
// 'useResponse'
|
|
// 'useResponse'
|
|
// ]
|
|
// ]
|
|
- },
|
|
|
|
|
|
+ }
|
|
],
|
|
],
|
|
- resolvers: [ElementPlusResolver()],
|
|
|
|
- dts: 'src/auto-imports.d.ts', // 生成 TypeScript 声明文件
|
|
|
|
|
|
+ resolvers: [ ElementPlusResolver() ],
|
|
|
|
+ dts: 'src/auto-imports.d.ts' // 生成 TypeScript 声明文件
|
|
}),
|
|
}),
|
|
Components({
|
|
Components({
|
|
// resolvers: [ElementPlusResolver()],
|
|
// resolvers: [ElementPlusResolver()],
|
|
@@ -58,7 +58,7 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
algorithm: 'gzip', // 使用 gzip 压缩
|
|
algorithm: 'gzip', // 使用 gzip 压缩
|
|
ext: '.gz', // 输出的文件扩展名
|
|
ext: '.gz', // 输出的文件扩展名
|
|
threshold: 10240, // 只有大小大于该值的资源会被压缩(默认 10KB)
|
|
threshold: 10240, // 只有大小大于该值的资源会被压缩(默认 10KB)
|
|
- deleteOriginFile: false, // 是否删除原始未压缩的文件
|
|
|
|
|
|
+ deleteOriginFile: false // 是否删除原始未压缩的文件
|
|
}),
|
|
}),
|
|
lazyImport({
|
|
lazyImport({
|
|
resolvers: [
|
|
resolvers: [
|
|
@@ -75,7 +75,12 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
resolve: { alias },
|
|
resolve: { alias },
|
|
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
|
|
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
|
|
optimizeDeps: {
|
|
optimizeDeps: {
|
|
- include: [ 'element-plus/es/locale/lang/zh-cn', 'element-plus/es/locale/lang/en', 'element-plus/es/locale/lang/zh-tw' ]
|
|
|
|
|
|
+ include: [
|
|
|
|
+ 'element-plus/es/locale/lang/zh-cn',
|
|
|
|
+ 'element-plus/es/locale/lang/en',
|
|
|
|
+ 'element-plus/es/locale/lang/zh-tw',
|
|
|
|
+ '@fast-crud/fast-crud'
|
|
|
|
+ ]
|
|
},
|
|
},
|
|
server: {
|
|
server: {
|
|
host: '0.0.0.0',
|
|
host: '0.0.0.0',
|
|
@@ -103,7 +108,7 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
manualChunks: {
|
|
manualChunks: {
|
|
vue: [ 'vue', 'vue-router', 'pinia' ],
|
|
vue: [ 'vue', 'vue-router', 'pinia' ],
|
|
echarts: [ 'echarts' ],
|
|
echarts: [ 'echarts' ],
|
|
- elementPlus: ['element-plus'],
|
|
|
|
|
|
+ elementPlus: [ 'element-plus' ]
|
|
}
|
|
}
|
|
// manualChunks(id) {
|
|
// manualChunks(id) {
|
|
// if (id.includes('node_modules')) {
|
|
// if (id.includes('node_modules')) {
|
|
@@ -113,11 +118,11 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- css: {
|
|
|
|
- preprocessorOptions: {
|
|
|
|
|
|
+ css: {
|
|
|
|
+ preprocessorOptions: {
|
|
css: { charset: false },
|
|
css: { charset: false },
|
|
- scss: { api: 'modern-compiler' },
|
|
|
|
- }
|
|
|
|
|
|
+ scss: { api: 'modern-compiler' }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
define: {
|
|
define: {
|
|
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
|
|
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
|