40 lines
964 B
TypeScript
40 lines
964 B
TypeScript
import path from 'node:path';
|
|
|
|
import { defineConfig, loadEnv } from '@farmfe/core';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import mkcert from 'vite-plugin-mkcert';
|
|
|
|
// @ts-ignore
|
|
export default defineConfig(({ mode }) => {
|
|
console.log('mode', mode);
|
|
const env = loadEnv(mode, process.cwd(), ['VITE_', 'Y_CODE_']);
|
|
|
|
return {
|
|
server: {
|
|
port: Number(env.VITE_PORT),
|
|
cors: true,
|
|
},
|
|
// @ts-ignore coding
|
|
vitePlugins: [vue(), mkcert({ source: 'coding' })],
|
|
compilation: {
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(process.cwd(), 'src'),
|
|
$vtj: path.resolve(process.cwd(), '.vtj'),
|
|
},
|
|
},
|
|
define: {
|
|
// 注入环境变量到客户端
|
|
'process.env': JSON.stringify(env),
|
|
},
|
|
// output: {
|
|
// path: path.resolve(process.cwd(), "../../dist/renderer"),
|
|
// clean: true,
|
|
// },
|
|
script: {
|
|
target: 'es2022',
|
|
},
|
|
},
|
|
};
|
|
});
|