42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig } from 'vite'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
import path from 'node:path'
|
|
import robots from './rollup-plugin-robots'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [tailwindcss(), vue(), vueDevTools(), robots()],
|
|
envDir: path.resolve('.', 'env'),
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vue: ['vue'],
|
|
'vue-router': ['vue-router'],
|
|
http: ['axios', 'qs'],
|
|
echarts: ['echarts'],
|
|
},
|
|
chunkFileNames: (chunkFileInfo) => {
|
|
for (const id of chunkFileInfo.moduleIds) {
|
|
const match = id.match(/\/pages\/([^/]+)/)
|
|
if (match) {
|
|
return `js/${match[1].toLocaleLowerCase()}-[hash].js`
|
|
}
|
|
}
|
|
|
|
return 'js/[name]-[hash].js'
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|