2024-05-27 23:02:39 +08:00
|
|
|
|
import { getPluginsList } from './build/plugins';
|
2024-05-28 10:02:35 +08:00
|
|
|
|
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
|
2024-05-11 14:48:02 +08:00
|
|
|
|
|
2024-05-28 10:02:35 +08:00
|
|
|
|
// Vite中文文档:https://cn.vitejs.dev/guide/build#browser-compatibility
|
2024-05-11 14:48:02 +08:00
|
|
|
|
export default ({ mode }: ConfigEnv): UserConfigExport => {
|
2024-05-28 10:02:35 +08:00
|
|
|
|
const { VITE_CDN, VITE_COMPRESSION } = wrapperEnv(loadEnv(mode, root));
|
2024-05-27 23:02:39 +08:00
|
|
|
|
return {
|
|
|
|
|
root,
|
2024-05-28 10:02:35 +08:00
|
|
|
|
resolve: { alias },
|
2024-05-27 23:02:39 +08:00
|
|
|
|
// 服务端渲染
|
2024-05-28 10:02:35 +08:00
|
|
|
|
server: serverOptions(mode),
|
|
|
|
|
// 插件相关
|
2024-05-27 23:02:39 +08:00
|
|
|
|
plugins: getPluginsList(VITE_CDN, VITE_COMPRESSION),
|
2024-05-28 10:02:35 +08:00
|
|
|
|
optimizeDeps: { include, exclude },
|
|
|
|
|
esbuild: {
|
|
|
|
|
pure: ['console.log', 'debugger'],
|
|
|
|
|
jsxFactory: 'h',
|
|
|
|
|
jsxFragment: 'Fragment',
|
|
|
|
|
jsxInject: "import { h } from 'vue';",
|
2024-05-27 23:02:39 +08:00
|
|
|
|
},
|
2024-05-28 10:02:35 +08:00
|
|
|
|
build: buildEnvironment(),
|
2024-05-27 23:02:39 +08:00
|
|
|
|
define: {
|
|
|
|
|
__INTLIFY_PROD_DEVTOOLS__: false,
|
|
|
|
|
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
|
|
|
|
},
|
|
|
|
|
};
|
2024-05-11 14:48:02 +08:00
|
|
|
|
};
|