55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import Icons from 'unplugin-icons/vite'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import { autoImportConfig, componentsConfig } from './config/plugins.js'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(({ _command, mode }) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
console.log('Environment variables:', env)
|
|
return {
|
|
base: env.VITE_BASE_URL,
|
|
optimizeDeps: {
|
|
exclude: ['vue-element-plus-x']
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'~': fileURLToPath(new URL('./', import.meta.url)),
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
autoImportConfig,
|
|
componentsConfig,
|
|
Icons({
|
|
autoInstall: true
|
|
})
|
|
],
|
|
build: {
|
|
chunkSizeWarningLimit: 2000,
|
|
outDir: 'dist',
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
compress: {
|
|
keep_infinity: true,
|
|
drop_console: true,
|
|
drop_debugger: true
|
|
},
|
|
format: {
|
|
comments: false
|
|
}
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
chunkFileNames: 'static/js/[name]-[hash].js',
|
|
entryFileNames: 'static/js/[name]-[hash].js',
|
|
assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
|
|
}
|
|
}
|
|
},
|
|
envPrefix: ['VITE', 'FILE']
|
|
}
|
|
})
|