mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import react from '@vitejs/plugin-react';
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
|
|
import { dependencies } from './package.json';
|
|
|
|
const inlinePackages = ['react', 'react-router-dom', 'react-dom'];
|
|
function renderChunks(deps: Record<string, string>) {
|
|
const chunks = {};
|
|
Object.keys(deps).forEach((key) => {
|
|
if (inlinePackages.includes(key)) {
|
|
return;
|
|
}
|
|
chunks[key] = [key];
|
|
})
|
|
return chunks;
|
|
}
|
|
|
|
// https://vitejs.dev/config/
|
|
export default (({ mode }: { mode: string }) => {
|
|
process.env = {
|
|
...process.env,
|
|
...loadEnv(mode, process.cwd())
|
|
};
|
|
const enableHttps = process.env.VITE_PORTAL_FRONT_HTTPS === 'true';
|
|
return defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
port: Number(process.env.VITE_PORTAL_FRONT_PORT),
|
|
|
|
// NOTE: https is not used for dev builds currently
|
|
https: enableHttps,
|
|
},
|
|
build: {
|
|
chunkSizeWarningLimit: 4000, // KB
|
|
sourcemap: false,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
// Load chunks for dependencies separately
|
|
...renderChunks(dependencies),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
});
|
|
});
|