73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
|
|
import type { PluginOption } from 'vite';
|
||
|
|
import process from 'node:process';
|
||
|
|
import { fileURLToPath, URL } from 'node:url';
|
||
|
|
import mswMockPlugin from '@lingshu/vite-plugin-msw';
|
||
|
|
import sharePlugin from '@lingshu/vite-plugin-share';
|
||
|
|
import replacePlugin from '@rollup/plugin-replace';
|
||
|
|
import vue from '@vitejs/plugin-vue';
|
||
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||
|
|
import UnoCSS from 'unocss/vite';
|
||
|
|
import { defineConfig, loadEnv } from 'vite';
|
||
|
|
import vueDevTools from 'vite-plugin-vue-devTools';
|
||
|
|
|
||
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
||
|
|
const base = '/micro/app-name';
|
||
|
|
|
||
|
|
console.log('test => ', `has rendered`);
|
||
|
|
|
||
|
|
export default defineConfig((configEnv) => {
|
||
|
|
const apiBase = loadEnv(configEnv.mode, process.cwd()).VITE_API_BASE;
|
||
|
|
return {
|
||
|
|
base,
|
||
|
|
define: {
|
||
|
|
'process.env': process.env,
|
||
|
|
},
|
||
|
|
plugins: [
|
||
|
|
vue(),
|
||
|
|
vueJsx(),
|
||
|
|
UnoCSS(),
|
||
|
|
mswMockPlugin(configEnv.mode),
|
||
|
|
sharePlugin(configEnv, { debug: true }),
|
||
|
|
vueDevTools(),
|
||
|
|
replacePlugin({
|
||
|
|
preventAssignment: true,
|
||
|
|
__CONDITIONAL_IMPORT__: isProduction ? `./BuildImport.ts` : './DevImport.ts',
|
||
|
|
}) as PluginOption,
|
||
|
|
],
|
||
|
|
oxc: isProduction
|
||
|
|
? {
|
||
|
|
define: {
|
||
|
|
'console.log': 'void 0',
|
||
|
|
'console.info': 'void 0',
|
||
|
|
'console.warn': 'void 0',
|
||
|
|
'console.debug': 'void 0',
|
||
|
|
'console.error': 'void 0',
|
||
|
|
'debugger': 'void 0',
|
||
|
|
},
|
||
|
|
}
|
||
|
|
: undefined,
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'~': fileURLToPath(new URL('./src', import.meta.url)),
|
||
|
|
'@lingshu/ai-agents': fileURLToPath(new URL('../ai-agents/src/index.ts', import.meta.url)),
|
||
|
|
'@lingshu/types': fileURLToPath(new URL('../types', import.meta.url)),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
sourcemap: false,
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
open: true,
|
||
|
|
host: true,
|
||
|
|
port: 5100,
|
||
|
|
proxy: {
|
||
|
|
'/api': {
|
||
|
|
target: apiBase,
|
||
|
|
changeOrigin: true,
|
||
|
|
ws: false,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
};
|
||
|
|
});
|