1 Star 0 Fork 14

量子风暴/TangSengDaoDaoManager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 3.09 KB
一键复制 编辑 原始数据 按行查看 历史
budou 提交于 2023-08-12 22:26 . perf: 👌代码优化
import { defineConfig, ConfigEnv, UserConfig } from 'vite';
import { resolve } from 'path';
// vite插件
import VueDevTools from 'vite-plugin-vue-devtools';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import unocss from '@unocss/vite';
import { createHtmlPlugin } from 'vite-plugin-html';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import setupExtend from 'unplugin-vue-setup-extend-plus/vite';
import Layouts from 'vite-plugin-vue-meta-layouts';
import Pages from 'vite-plugin-pages';
import compression from 'vite-plugin-compression';
const getPlugins = (_command?: string) => {
return [
AutoImport({
include: [/\.[tj]sx?$/, /\.vue\?vue/, /\.md$/],
imports: ['vue', 'vue-router', 'pinia'],
resolvers: [],
dts: 'src/types/auto-imports.d.ts'
}),
Components({
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
resolvers: [],
dts: 'src/types/components.d.ts'
}),
VueDevTools(),
vue({
template: {
compilerOptions: {
isCustomElement: tag => /^tgs-player/.test(tag)
}
}
}),
vueJsx(),
createHtmlPlugin({
inject: {
data: {
title: '唐僧叨叨后台管理',
injectScript: process.env.IS_CONFIG ? `<script src="/tsdd-config.js"></script>` : null
}
}
}),
unocss(),
setupExtend({}),
Layouts({
defaultLayout: 'index'
}),
Pages({
dirs: 'src/pages',
exclude: ['**/components/*.vue']
}),
compression({
ext: '.gz',
deleteOriginFile: false
})
];
};
export default defineConfig(({ command }: ConfigEnv): UserConfig => {
return {
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
}
},
define: {
'process.env': {
APP_ENV: process.env.APP_ENV
}
},
plugins: getPlugins(command),
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: atRule => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
]
},
preprocessorOptions: {
scss: {
additionalData: `@import "@/styles/var.scss";`
}
}
},
server: {
host: '0.0.0.0'
},
build: {
cssCodeSplit: false,
sourcemap: false,
emptyOutDir: true,
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks: {
// 分包配置,配置完成自动按需加载
vue: ['vue', 'vue-router', 'pinia', 'vue-i18n', 'element-plus'],
echarts: ['echarts'],
'tgs-player': ['@lottiefiles/lottie-player/dist/tgs-player']
}
}
}
}
};
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuchunfu/TangSengDaoDaoManager.git
git@gitee.com:wuchunfu/TangSengDaoDaoManager.git
wuchunfu
TangSengDaoDaoManager
TangSengDaoDaoManager
main

搜索帮助