perf: Improve the global loading display
This commit is contained in:
@@ -7,11 +7,11 @@ import { defineConfig, loadEnv, mergeConfig } from 'vite';
|
||||
import { getApplicationConditionPlugins } from '../plugins';
|
||||
import { getCommonConfig } from './common';
|
||||
|
||||
import type { DefineAppcationOptions } from '../typing';
|
||||
import type { DefineApplicationOptions } from '../typing';
|
||||
|
||||
function defineApplicationConfig(options: DefineAppcationOptions = {}) {
|
||||
function defineApplicationConfig(options: DefineApplicationOptions = {}) {
|
||||
return defineConfig(async ({ command, mode }) => {
|
||||
const { appcation = {}, vite = {} } = options;
|
||||
const { application = {}, vite = {} } = options;
|
||||
const root = process.cwd();
|
||||
const isBuild = command === 'build';
|
||||
const env = loadEnv(mode, root);
|
||||
@@ -29,11 +29,10 @@ function defineApplicationConfig(options: DefineAppcationOptions = {}) {
|
||||
mock: true,
|
||||
mode,
|
||||
turboConsole: false,
|
||||
...appcation,
|
||||
...application,
|
||||
});
|
||||
|
||||
const applicationConfig: UserConfig = {
|
||||
// },
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
@@ -44,7 +43,6 @@ function defineApplicationConfig(options: DefineAppcationOptions = {}) {
|
||||
},
|
||||
target: 'es2015',
|
||||
},
|
||||
// },
|
||||
esbuild: {
|
||||
drop: isBuild
|
||||
? [
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { fs } from '@vben/node-utils';
|
||||
|
||||
import { defineApplicationConfig } from './application';
|
||||
import { defineLibraryConfig } from './library';
|
||||
|
||||
@@ -18,13 +17,19 @@ function defineConfig(options: DefineConfig = {}) {
|
||||
// 根据包是否存在 index.html,自动判断类型
|
||||
if (type === 'auto') {
|
||||
const htmlPath = join(process.cwd(), 'index.html');
|
||||
projectType = fs.existsSync(htmlPath) ? 'appcation' : 'library';
|
||||
projectType = existsSync(htmlPath) ? 'application' : 'library';
|
||||
}
|
||||
|
||||
if (projectType === 'appcation') {
|
||||
return defineApplicationConfig(defineOptions);
|
||||
} else if (projectType === 'library') {
|
||||
return defineLibraryConfig(defineOptions);
|
||||
switch (projectType) {
|
||||
case 'application': {
|
||||
return defineApplicationConfig(defineOptions);
|
||||
}
|
||||
case 'library': {
|
||||
return defineLibraryConfig(defineOptions);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported project type: ${projectType}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@ function defineLibraryConfig(options: DefineLibraryOptions = {}) {
|
||||
build: {
|
||||
lib: {
|
||||
entry: 'src/index.ts',
|
||||
fileName: () => 'index.mjs',
|
||||
fileName: 'index.mjs',
|
||||
formats: ['es'],
|
||||
},
|
||||
rollupOptions: {
|
||||
|
Reference in New Issue
Block a user