low-code/apps/designer/vite.config.ts

53 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { createViteConfig } from '@vtj/cli';
import { createDevTools } from '@vtj/local';
import AutoImport from 'unplugin-auto-import/vite';
import { defineConfig, loadEnv } from 'vite';
import mkcert from 'vite-plugin-mkcert';
const config = createViteConfig({
// proxy,
plugins: [
createDevTools(),
mkcert(),
AutoImport({
imports: [
'vue',
'pinia',
'vue-router',
{
from: 'pinia',
imports: ['storeToRefs', 'defineStore'],
type: true
}
],
dts: 'src/auto-imports.d.ts', // 生成类型声明文件
eslintrc: {
enabled: true // 生成 eslint 配置
}
})
]
});
// @ts-ignore
export default defineConfig(({ mode }) => {
console.log('mode', mode);
// 加载环境变量(支持 .env.development/.env.production
const env = loadEnv(mode, process.cwd(), ['VITE_', 'VTJ_', 'SY_', 'Y_CODE_']);
return {
...config,
server: {
https: true,
port: env.VITE_PORT,
host: true
},
define: {
// 注入环境变量到客户端
__APP_ENV__: JSON.stringify(env)
}
// build: {
// outDir: path.resolve(process.cwd(), '../../dist/designer'),
// emptyOutDir: true // 构建前清空目录
// }
};
});