mirror of
https://github.com/Snigdha-OS/Snigdha-OS.github.io.git
synced 2025-09-07 13:15:17 +02:00
🧹 chore: optimize vite config
This commit is contained in:
@@ -3,39 +3,59 @@ import react from '@vitejs/plugin-react';
|
|||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import ViteSitemap from 'vite-plugin-sitemap';
|
import ViteSitemap from 'vite-plugin-sitemap';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
plugins: [
|
const isProduction = mode === 'production';
|
||||||
react(),
|
|
||||||
ViteSitemap({
|
return {
|
||||||
hostname: 'https://www.snigdhaos.org',
|
plugins: [
|
||||||
outDir: './dist',
|
react(),
|
||||||
changefreq: 'daily',
|
ViteSitemap({
|
||||||
priority: 0.7,
|
hostname: process.env.VITE_SITE_URL || 'https://www.snigdhaos.org',
|
||||||
// lastmod: true,
|
outDir: './dist',
|
||||||
}),
|
changefreq: 'daily',
|
||||||
],
|
priority: 0.7,
|
||||||
resolve: {
|
}),
|
||||||
alias: {
|
],
|
||||||
'@': resolve(__dirname, './src'),
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': resolve(__dirname, './src'),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
css: {
|
||||||
build: {
|
preprocessorOptions: {
|
||||||
rollupOptions: {
|
scss: {
|
||||||
output: {
|
additionalData: `@import "@/styles/global.scss";`, // Import global SCSS
|
||||||
entryFileNames: 'script.js',
|
|
||||||
assetFileNames: ({ name }) => {
|
|
||||||
if (name && name.endsWith('.css')) {
|
|
||||||
return 'style.css';
|
|
||||||
}
|
|
||||||
return 'assets/[name]-[hash][extname]';
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
build: {
|
||||||
optimizeDeps: {
|
rollupOptions: {
|
||||||
exclude: ['lucide-react'],
|
output: {
|
||||||
},
|
entryFileNames: 'script.js',
|
||||||
server: {
|
chunkFileNames: 'chunk-[name]-[hash].js',
|
||||||
open: true, // Automatically open the browser when running the development server
|
assetFileNames: ({ name }) => {
|
||||||
},
|
if (name && name.endsWith('.css')) {
|
||||||
|
return 'style.css';
|
||||||
|
}
|
||||||
|
return 'assets/[name]-[hash][extname]';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
terserOptions: {
|
||||||
|
compress: {
|
||||||
|
drop_console: isProduction, // Remove console logs in production
|
||||||
|
drop_debugger: isProduction, // Remove debugger in production
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
optimizeDeps: {
|
||||||
|
exclude: ['lucide-react'],
|
||||||
|
},
|
||||||
|
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
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user