- 添加代码混淆插件和分包插件 - 更新 .gitignore 文件,忽略自动导入文件 - 删除无用的类型定义文件 - 移除 VS Code 扩展推荐文件 -优化 Vite 配置,美化构建输出结构
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
import { chunkSplitPlugin } from 'vite-plugin-chunk-split';
|
|
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator';
|
|
import {
|
|
AntDesignVueResolver,
|
|
IduxResolver,
|
|
NaiveUiResolver
|
|
} from 'unplugin-vue-components/resolvers';
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
server: {
|
|
host: '0.0.0.0',
|
|
proxy: {
|
|
'/api': 'http://localhost:7546',
|
|
},
|
|
},
|
|
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
chunkFileNames: `assets/[name]/[hash].js`,
|
|
entryFileNames: `assets/[name]/[hash].js`,
|
|
assetFileNames: `assets/[name]/[hash].[ext]`,
|
|
},
|
|
},
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueDevTools(),
|
|
chunkSplitPlugin({
|
|
strategy: 'single-vendor',
|
|
}),
|
|
AutoImport({
|
|
imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
|
|
dts: 'src/types/ts.auto.import.d.ts',
|
|
}),
|
|
vitePluginBundleObfuscator({
|
|
excludes: [],
|
|
enable: true,
|
|
log: true,
|
|
autoExcludeNodeModules: true,
|
|
threadPool: true,
|
|
}),
|
|
Components({
|
|
resolvers: [
|
|
IduxResolver({
|
|
importStyle: 'css',
|
|
}),
|
|
NaiveUiResolver(),
|
|
AntDesignVueResolver({
|
|
resolveIcons: true,
|
|
importStyle: 'less',
|
|
}),
|
|
],
|
|
dts: 'src/types/components.auto.import.d.ts',
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'@res': fileURLToPath(new URL('./src/resource', import.meta.url)),
|
|
'@com': fileURLToPath(new URL('./src/component', import.meta.url)),
|
|
},
|
|
},
|
|
});
|