feat(vite-plugins): 使用 consola 替换 console.log 以增强日志输出
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import type { ConfigEnv, PluginOption } from 'vite';
|
||||
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import Icons from 'unplugin-icons/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
|
||||
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
||||
import { createUtils4uAutoImports } from 'utils4u/auto-imports';
|
||||
@@ -23,6 +23,7 @@ import IconsResolver from 'unplugin-icons/resolver';
|
||||
import { VantResolver } from '@vant/auto-import-resolver';
|
||||
// <<<<<
|
||||
|
||||
import consola from 'consola';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -33,7 +34,7 @@ function _getNaiveUiComponentNames() {
|
||||
const webTypes = JSON.parse(fs.readFileSync(webTypesPath, 'utf-8'));
|
||||
const components = webTypes.contributions.html['vue-components'];
|
||||
const componentNames = components.map((component: { name: string }) => component.name);
|
||||
console.log('naive-ui components count (from web-types.json):', componentNames.length);
|
||||
consola.info('naive-ui components count (from web-types.json):', componentNames.length);
|
||||
return componentNames;
|
||||
}
|
||||
|
||||
@@ -45,11 +46,11 @@ function _getNaiveUiComponentNames() {
|
||||
const regex = /^\s+(N\w+):/gm;
|
||||
const matches = [...volarContent.matchAll(regex)];
|
||||
const componentNames = matches.map((match) => match[1]);
|
||||
console.log('naive-ui components count (from volar.d.ts):', componentNames.length);
|
||||
consola.info('naive-ui components count (from volar.d.ts):', componentNames.length);
|
||||
return componentNames;
|
||||
}
|
||||
|
||||
console.warn('Could not find naive-ui component metadata files');
|
||||
consola.warn('Could not find naive-ui component metadata files');
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { consola } from 'consola';
|
||||
import type { ConfigEnv, PluginOption } from 'vite';
|
||||
import { vitePluginFakeServer } from 'vite-plugin-fake-server';
|
||||
// https://github.com/condorheroblog/vite-plugin-fake-server?tab=readme-ov-file#usage
|
||||
|
||||
export function loadPlugin(_configEnv: ConfigEnv): PluginOption {
|
||||
if (_configEnv.mode === 'test') {
|
||||
console.log('fake server plugin disabled in test mode');
|
||||
if (_configEnv.mode !== 'development') {
|
||||
consola.info('fake server plugin disabled in test mode');
|
||||
return [];
|
||||
}
|
||||
return vitePluginFakeServer({
|
||||
|
||||
Reference in New Issue
Block a user