pokerogue/vite.config.ts
Adrián T. 37b06a5b77
[Refactor] Automate namespace collection for en locale (#4625)
* create and use namespace-i18n-plugin.ts

* Changes to src/utils.ts to ensure correct importing by Vite plugins and extraction of the
amespaceMap constant to its own file.

* Added more comments for create help a new namespace

* create utils-plugins.ts and more docs

* console info appearance

* chore: handle merge conflicts

* chore: run biome

* add biome to namespace map dropped after merge

---------

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
2025-10-06 11:15:05 -05:00

48 lines
1.4 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2024-2025 Pagefault Games
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineConfig, loadEnv, type Rollup, type UserConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { LocaleNamespace } from "./src/plugins/vite/namespaces-i18n-plugin";
import { minifyJsonPlugin } from "./src/plugins/vite/vite-minify-json-plugin";
export const defaultConfig: UserConfig = {
plugins: [tsconfigPaths(), minifyJsonPlugin(["images", "battle-anims"], true), LocaleNamespace()],
clearScreen: false,
appType: "mpa",
build: {
chunkSizeWarningLimit: 10000,
minify: "esbuild",
sourcemap: false,
rollupOptions: {
onwarn(warning: Rollup.RollupLog, defaultHandler: (warning: string | Rollup.RollupLog) => void) {
// Suppress "Module level directives cause errors when bundled" warnings
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
return;
}
defaultHandler(warning);
},
},
},
};
export default defineConfig(({ mode, command }) => {
const envPort = Number(loadEnv(mode, process.cwd()).VITE_PORT);
return {
...defaultConfig,
base: "",
publicDir: command === "serve" ? "assets" : false,
esbuild: {
pure: mode === "production" ? ["console.log"] : [],
keepNames: true,
},
server: {
port: !Number.isNaN(envPort) ? envPort : 8000,
},
};
});