2024-07-13 02:20:22 +01:00
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
2024-06-16 05:26:37 +01:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
|
|
|
|
export const defaultConfig = {
|
|
|
|
plugins: [tsconfigPaths() as any],
|
|
|
|
clearScreen: false,
|
|
|
|
build: {
|
|
|
|
minify: 'esbuild' as const,
|
|
|
|
sourcemap: false,
|
|
|
|
},
|
|
|
|
rollupOptions: {
|
|
|
|
onwarn(warning, warn) {
|
|
|
|
// Suppress "Module level directives cause errors when bundled" warnings
|
|
|
|
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
warn(warning);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-07-13 02:20:22 +01:00
|
|
|
export default defineConfig(({mode}) => {
|
|
|
|
const envPort = Number(loadEnv(mode, process.cwd()).VITE_PORT);
|
|
|
|
|
|
|
|
return ({
|
|
|
|
...defaultConfig,
|
|
|
|
esbuild: {
|
|
|
|
pure: mode === 'production' ? ['console.log'] : [],
|
|
|
|
keepNames: true,
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
port: !isNaN(envPort) ? envPort : 8000,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|