mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 11:35:58 +08:00
chore: init project
This commit is contained in:
31
internal/vite-config/src/config/index.ts
Normal file
31
internal/vite-config/src/config/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { fs } from '@vben/node-utils';
|
||||
|
||||
import { defineApplicationConfig } from './application';
|
||||
import { defineLibraryConfig } from './library';
|
||||
|
||||
import type { DefineConfig } from '../typing';
|
||||
|
||||
export * from './application';
|
||||
export * from './library';
|
||||
|
||||
function defineConfig(options: DefineConfig = {}) {
|
||||
const { type = 'auto', ...defineOptions } = options;
|
||||
|
||||
let projectType = type;
|
||||
|
||||
// 根据包是否存在 index.html,自动判断类型
|
||||
if (type === 'auto') {
|
||||
const htmlPath = join(process.cwd(), 'index.html');
|
||||
projectType = fs.existsSync(htmlPath) ? 'appcation' : 'library';
|
||||
}
|
||||
|
||||
if (projectType === 'appcation') {
|
||||
return defineApplicationConfig(defineOptions);
|
||||
} else if (projectType === 'library') {
|
||||
return defineLibraryConfig(defineOptions);
|
||||
}
|
||||
}
|
||||
|
||||
export { defineConfig };
|
Reference in New Issue
Block a user