🧹 chore: optimize vite config

This commit is contained in:
eshanized
2025-01-13 14:02:56 +05:30
parent 14f89ed2c2
commit 2a35172f8d

View File

@@ -3,15 +3,17 @@ import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import ViteSitemap from 'vite-plugin-sitemap';
export default defineConfig({
export default defineConfig(({ mode }) => {
const isProduction = mode === 'production';
return {
plugins: [
react(),
ViteSitemap({
hostname: 'https://www.snigdhaos.org',
hostname: process.env.VITE_SITE_URL || 'https://www.snigdhaos.org',
outDir: './dist',
changefreq: 'daily',
priority: 0.7,
// lastmod: true,
}),
],
resolve: {
@@ -19,10 +21,18 @@ export default defineConfig({
'@': resolve(__dirname, './src'),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "@/styles/global.scss";`, // Import global SCSS
},
},
},
build: {
rollupOptions: {
output: {
entryFileNames: 'script.js',
chunkFileNames: 'chunk-[name]-[hash].js',
assetFileNames: ({ name }) => {
if (name && name.endsWith('.css')) {
return 'style.css';
@@ -31,11 +41,21 @@ export default defineConfig({
},
},
},
terserOptions: {
compress: {
drop_console: isProduction, // Remove console logs in production
drop_debugger: isProduction, // Remove debugger in production
},
},
},
optimizeDeps: {
exclude: ['lucide-react'],
},
server: {
open: true, // Automatically open the browser when running the development server
open: true,
port: 5173, // Default port
strictPort: false, // Allow using a different port if 5173 is taken
},
envDir: './env', // Define directory for environment variables
};
});