45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
|
// import { createSplitChunkOutput } from 'utils4u/rollup';
|
|
import { createViteProxy } from 'utils4u/vite';
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
import { Plugins } from './vite.config.plugins';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode, command }) => {
|
|
const isBuild = command === 'build';
|
|
const env = loadEnv(mode, process.cwd());
|
|
|
|
return {
|
|
base: env.VITE_BASE,
|
|
plugins: Plugins(),
|
|
define: {
|
|
$__DEV__: JSON.stringify(!isBuild),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
proxy: createViteProxy(),
|
|
},
|
|
build: {
|
|
sourcemap: mode !== 'production' || env.VITE_SOURCE_MAP === 'true',
|
|
rollupOptions: {
|
|
onwarn: (warning, warn) => {
|
|
if (warning.code === 'EMPTY_BUNDLE') return;
|
|
if (warning.code === 'EVAL' && warning.id?.includes('node_modules/eruda')) return;
|
|
if (warning.code === 'EVAL' && warning.id?.includes('node_modules/mockjs')) return;
|
|
warn(warning);
|
|
},
|
|
|
|
// https://cn.rollupjs.org/configuration-options/#output-assetfilenames
|
|
// output: env.VITE_SPLIT_CHUNKS === 'true' ? (await import('utils4u/rollup')).createSplitChunkOutput() : undefined,
|
|
output: {
|
|
minifyInternalExports: false,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|