32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { getPluginsList } from './build/plugins';
|
||
import { exclude, include } from './build/optimize';
|
||
import { type ConfigEnv, loadEnv, type UserConfigExport } from 'vite';
|
||
import { __APP_INFO__, alias, root, wrapperEnv } from './build/utils';
|
||
import { buildEnvironment } from './build/buildEnv';
|
||
import { serverOptions } from './build/server'; // Vite中文文档:https://cn.vitejs.dev/guide/build#browser-compatibility
|
||
|
||
// Vite中文文档:https://cn.vitejs.dev/guide/build#browser-compatibility
|
||
export default ({ mode }: ConfigEnv): UserConfigExport => {
|
||
const { VITE_CDN, VITE_COMPRESSION } = wrapperEnv(loadEnv(mode, root));
|
||
return {
|
||
root,
|
||
resolve: { alias },
|
||
// 服务端渲染
|
||
server: serverOptions(mode),
|
||
// 插件相关
|
||
plugins: getPluginsList(VITE_CDN, VITE_COMPRESSION),
|
||
optimizeDeps: { include, exclude },
|
||
esbuild: {
|
||
pure: ['console.log', 'debugger'],
|
||
jsxFactory: 'h',
|
||
jsxFragment: 'Fragment',
|
||
jsxInject: "import { h } from 'vue';",
|
||
},
|
||
build: buildEnvironment(),
|
||
define: {
|
||
__INTLIFY_PROD_DEVTOOLS__: false,
|
||
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
||
},
|
||
};
|
||
};
|