pokerogue/vite.config.ts
flx-sta 2bd07cb84e
fix and optimize imports (#4061)
- remove any `.js` extension imports
- remove unncessary dynamic imports of `modifier.ts` file. The file was being imported statically & dynamically. Made it pure static
- increase vite chunk-size warning limit

Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com>
2024-09-07 21:37:37 -07:00

43 lines
1.0 KiB
TypeScript

import { defineConfig, loadEnv, Rollup, 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}) => {
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,
}
});
});