| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- /**
- * Copyright (c) 2013-Now https://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 './build';
- 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: {
- '@build': path.resolve(__dirname, 'build'),
- '@': path.resolve(__dirname, 'src'),
- },
- },
- };
- return config;
- });
|