pokerogue/vite.config.ts
flx-sta d3e5a68f10
[Optimization] Minify json files in build directory (after beta rebase) (#3214)
* add and use minify-json vite plugin

it minifies all the json files in the given directorties (currently `/dist/images` and `/dist/battle-anim`). That way we can work with the beautified jsons but the users retrieve the minified ones.

* bump vite to v5 to fix typedoc issue

https://github.com/vitejs/vite/issues/15714
2024-07-29 19:13:36 -04:00

41 lines
907 B
TypeScript

import { defineConfig, loadEnv } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { minifyJsonPlugin } from "./src/plugins/vite/vite-minify-json-plugin";
export const defaultConfig = {
plugins: [
tsconfigPaths() as any,
minifyJsonPlugin(["images", "battle-anims"], true)
],
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);
},
}
};
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,
}
});
});