pokerogue/vite.config.ts
Sirz Benjie c695df777c
[Refactor][Dev] Move public to its own submodule (#6590)
* Remove public folder to prepare for submodule

* Add submodule and update licensing

* Stop serving non-asset files during build

* Update pull request template

* Update CODEOWNERS

* Add locales submodule

* Update pull request template regarding locales

* remove post-checkout lefthook in favor of git config

* chore: add license info to new script

* Update gh pages workflow

* Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* update assets
2025-09-27 11:01:12 -05:00

47 lines
1.3 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 { minifyJsonPlugin } from "./src/plugins/vite/vite-minify-json-plugin";
export const defaultConfig: UserConfig = {
plugins: [tsconfigPaths(), minifyJsonPlugin(["images", "battle-anims"], true)],
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,
},
};
});