tmp
This commit is contained in:
81
vite.config.js
Normal file
81
vite.config.js
Normal file
@@ -0,0 +1,81 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
const isProd = mode === 'production'
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
vue(),
|
||||
!isProd && vueDevTools(),
|
||||
].filter(Boolean),
|
||||
|
||||
resolve: {
|
||||
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
||||
},
|
||||
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
open: true,
|
||||
hmr: { overlay: true },
|
||||
},
|
||||
|
||||
build: {
|
||||
sourcemap: env.VITE_ENABLE_SOURCE_MAP === 'true',
|
||||
minify: isProd ? 'terser' : false,
|
||||
terserOptions: isProd ? {
|
||||
compress: {
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
},
|
||||
} : {},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: (id) => {
|
||||
if (id.includes('node_modules')) {
|
||||
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
|
||||
return 'vue-vendor'
|
||||
}
|
||||
if (id.includes('axios')) {
|
||||
return 'http-vendor'
|
||||
}
|
||||
if (id.includes('moment')) {
|
||||
return 'date-vendor'
|
||||
}
|
||||
if (id.includes('choices.js') || id.includes('flatpickr')) {
|
||||
return 'ui-vendor'
|
||||
}
|
||||
if (id.includes('sweetalert2')) {
|
||||
return 'dialog-vendor'
|
||||
}
|
||||
return 'vendor'
|
||||
}
|
||||
},
|
||||
chunkFileNames: 'assets/js/[name]-[hash].js',
|
||||
entryFileNames: 'assets/js/[name]-[hash].js',
|
||||
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
||||
},
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'MODULE_BROKEN') {
|
||||
return
|
||||
}
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY') {
|
||||
return
|
||||
}
|
||||
if (warning.code === 'SOURCEMAP_ERROR') {
|
||||
return
|
||||
}
|
||||
if (warning.code === 'THIS_IS_UNDEFINED') {
|
||||
return
|
||||
}
|
||||
warn(warning)
|
||||
},
|
||||
},
|
||||
chunkSizeWarningLimit: 1000,
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user