chore(pack): optimize dependencies, reduce bundle size

This commit is contained in:
2025-06-05 13:52:05 -04:00
parent 74323247c9
commit 31ba18fa8d
145 changed files with 992 additions and 15921 deletions

View File

@@ -1,53 +1,66 @@
import {fileURLToPath, URL} from 'node:url'
import {defineConfig, loadEnv} from 'vite'
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import fs from 'fs';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { resolve } from 'path'
import { visualizer } from 'rollup-plugin-visualizer'
// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
// Load environment variables based on the mode
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
vue(),
VueI18nPlugin({
include: resolve(__dirname, 'src/locales/**')
})
],
server: {
https: {
key: fs.readFileSync('localhost-key.pem'),
cert: fs.readFileSync('localhost.pem'),
},
port: 5173, // Ensure this matches your WebStorm debug URL
open: true, // Automatically opens the browser
host: '0.0.0.0',
},
build: {
sourcemap: true, // Enable source maps for debugging
rollupOptions: {
output: {
format: 'es',
entryFileNames: '[name].[hash].js',
chunkFileNames: '[name].[hash].js',
assetFileNames: '[name].[hash].[ext]'
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
define: {
// Define a global constant __APP_ENV__ based on loaded environment variables
VITE_API_URL: JSON.stringify(env.VITE_API_URL),
VITE_STRIPE_API_KEY: JSON.stringify(env.VITE_STRIPE_API_KEY)
},
json: {
stringify: false
export default defineConfig(({ mode }) => {
// Load environment variables based on the mode
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
visualizer({
filename: './dist/stats.html',
open: true, // Automatically opens in browser
gzipSize: true,
brotliSize: true,
}),
vue(),
VueI18nPlugin({
include: resolve(__dirname, 'src/locales/**')
})
],
server: {
https: {
key: fs.readFileSync('localhost-key.pem'),
cert: fs.readFileSync('localhost.pem'),
},
port: 5173, // Ensure this matches your WebStorm debug URL
open: true, // Automatically opens the browser
host: '0.0.0.0',
},
build: {
sourcemap: true, // Enable source maps for debugging
rollupOptions: {
output: {
manualChunks: {
vue: ['vue'],
vuetify: ['vuetify'],
vendor: ['lodash', 'axios'], // adjust based on your deps
vuedraggable: ['vuedraggable']
},
format: 'es',
entryFileNames: '[name].[hash].js',
chunkFileNames: '[name].[hash].js',
assetFileNames: '[name].[hash].[ext]'
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
define: {
// Define a global constant __APP_ENV__ based on loaded environment variables
VITE_API_URL: JSON.stringify(env.VITE_API_URL),
VITE_STRIPE_API_KEY: JSON.stringify(env.VITE_STRIPE_API_KEY)
},
json: {
stringify: false
}
}
})