| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { fileURLToPath, URL } from 'node:url'
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import vueJsx from '@vitejs/plugin-vue-jsx'
- import vueDevTools from 'vite-plugin-vue-devtools'
- import tailwindcss from '@tailwindcss/vite'
- // https://vite.dev/config/
- export default defineConfig({
- plugins: [vue(), vueJsx(), vueDevTools(), tailwindcss()],
- base: '/admin/',
- build: {
- // 确保资源使用相对路径
- assetsDir: 'assets',
- // 强制刷新缓存
- cssCodeSplit: true,
- sourcemap: false,
- // 优化分块策略
- rollupOptions: {
- output: {
- // 使用内容 hash,确保文件变化时浏览器重新下载
- assetFileNames: 'assets/[name]-[hash][extname]',
- chunkFileNames: 'assets/[name]-[hash].js',
- entryFileNames: 'assets/[name]-[hash].js',
- // 手动分块,避免单个文件过大
- manualChunks: undefined
- }
- }
- },
- server: {
- host: '0.0.0.0',
- port: 5175
- },
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url))
- }
- }
- })
|