123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { URL, fileURLToPath } from 'node:url'
- import { defineConfig, loadEnv } from 'vite'
- import createVitePlugins from './config/plugins'
- export default defineConfig(({ command, mode }) => {
- const env = loadEnv(mode, process.cwd()) as ImportMetaEnv
- return {
-
- base: env.VITE_BASE,
-
- resolve: {
- alias: {
- '~': fileURLToPath(new URL('./', import.meta.url)),
- '@': fileURLToPath(new URL('./src', import.meta.url)),
- },
- },
-
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: `@import "@/styles/var.scss";`,
- api: 'modern-compiler',
- },
- },
- },
-
- optimizeDeps: {
- include: ['vue-draggable-plus'],
- },
- server: {
-
- open: true,
-
- proxy: {
- '/web': {
- target: env.VITE_API_BASE_URL,
- changeOrigin: true,
- secure: false,
- rewrite: (path) => path.replace(/^\/web/, ''),
- },
- },
- },
- plugins: createVitePlugins(env, command === 'build'),
-
- 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'],
- }
- })
|