40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
|
* No deletion without permission, or be held responsible to law.
|
|
* @author ThinkGem
|
|
*/
|
|
import type { UserConfig, ConfigEnv } from 'vite';
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
import path from 'path';
|
|
import {
|
|
createBuildOptions,
|
|
createCSSOptions,
|
|
createDefineOptions,
|
|
createEsBuildOptions,
|
|
createServerOptions,
|
|
createVitePlugins,
|
|
wrapperEnv,
|
|
} from '@jeesite/vite';
|
|
|
|
export default defineConfig(async ({ command, mode }: ConfigEnv) => {
|
|
const root = process.cwd();
|
|
const isBuild = command === 'build';
|
|
const viteEnv = wrapperEnv(loadEnv(mode, root));
|
|
const config: UserConfig = {
|
|
root,
|
|
base: viteEnv.VITE_PUBLIC_PATH,
|
|
define: await createDefineOptions(),
|
|
plugins: createVitePlugins(isBuild, viteEnv),
|
|
server: createServerOptions(viteEnv),
|
|
esbuild: createEsBuildOptions(viteEnv),
|
|
build: createBuildOptions(viteEnv),
|
|
css: createCSSOptions(),
|
|
resolve: {
|
|
alias: {
|
|
'@jeesite/web': path.resolve(__dirname, './'),
|
|
},
|
|
},
|
|
};
|
|
return config;
|
|
});
|