mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-12-01 19:27:47 +08:00
feat: 添加 console 配置,支持输出 version
This commit is contained in:
parent
2cc5915ea7
commit
0a9a12a314
@ -93,6 +93,22 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
### console
|
||||
|
||||
- 类型: `object`
|
||||
- 默认值:`{}`
|
||||
- 详情:
|
||||
用于控制应用启动的时候在 console 中打印的信息,目前仅支持 version
|
||||
- 示例:
|
||||
|
||||
```js
|
||||
export default {
|
||||
console: {
|
||||
version: true
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### define
|
||||
|
||||
- 类型: `object`
|
||||
|
@ -16,6 +16,7 @@ export default function () {
|
||||
require.resolve('./plugins/features/alias'),
|
||||
require.resolve('./plugins/features/autoprefixer'),
|
||||
require.resolve('./plugins/features/define'),
|
||||
require.resolve('./plugins/features/console'),
|
||||
require.resolve('./plugins/features/dynamicImport'),
|
||||
require.resolve('./plugins/features/globalCSS'),
|
||||
require.resolve('./plugins/features/inlineLimit'),
|
||||
|
@ -12,6 +12,8 @@ import DefaultContainer from './defaultContainer.vue';
|
||||
|
||||
{{{ entryCodeAhead }}}
|
||||
|
||||
{{{ CONSOLE }}}
|
||||
|
||||
const renderClient = (opts = {}) => {
|
||||
const { plugin, routes, rootElement } = opts;
|
||||
const rootContainer = plugin.applyPlugins({
|
||||
|
@ -13,6 +13,15 @@ export function importsToStr(imports) {
|
||||
});
|
||||
}
|
||||
|
||||
function getConsoleInfo(config, pkg) {
|
||||
if (config.console?.version) {
|
||||
return `
|
||||
console.log('%c[${pkg.name}]%c${pkg.version}', 'background-color: #1677ff; border-top-left-radius: 6px; border-bottom-left-radius: 6px; color: white; padding: 4px', 'background-color: #42b983; border-top-right-radius: 6px; border-bottom-right-radius: 6px; color: white; padding: 4px');
|
||||
`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export default function (api) {
|
||||
const {
|
||||
utils: { Mustache },
|
||||
@ -24,6 +33,7 @@ export default function (api) {
|
||||
path: 'fes.js',
|
||||
content: Mustache.render(fesTpl, {
|
||||
enableTitle: api.config.title !== false,
|
||||
CONSOLE: getConsoleInfo(api.config, api.pkg),
|
||||
defaultTitle: api.config.title || 'fes.js',
|
||||
runtimePath,
|
||||
rootElement: `#${api.config.mountElementId || 'app'}`,
|
||||
|
13
packages/fes-preset-built-in/src/plugins/features/console.js
Normal file
13
packages/fes-preset-built-in/src/plugins/features/console.js
Normal file
@ -0,0 +1,13 @@
|
||||
export default (api) => {
|
||||
api.describe({
|
||||
key: 'console',
|
||||
config: {
|
||||
default: {
|
||||
version: false,
|
||||
},
|
||||
schema(joi) {
|
||||
return joi.object().description('output info in console, default version');
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
17
packages/fes-preset-built-in/types.d.ts
vendored
17
packages/fes-preset-built-in/types.d.ts
vendored
@ -1,8 +1,8 @@
|
||||
import { Component, DefineComponent, Component, App } from 'vue';
|
||||
import { RouteRecordRaw, Router, RouterHistory, createMemoryHistory, createWebHashHistory, createWebHistory } from 'vue-router';
|
||||
import type { App, Component, DefineComponent } from 'vue';
|
||||
import type { createMemoryHistory, createWebHashHistory, createWebHistory, Router, RouteRecordRaw, RouterHistory } from 'vue-router';
|
||||
|
||||
// @ts-ignore
|
||||
import { Plugin } from '@fesjs/runtime';
|
||||
import type { Plugin } from '@fesjs/runtime';
|
||||
|
||||
interface BeforeRenderConfig {
|
||||
loading: Component;
|
||||
@ -44,6 +44,9 @@ declare module '@fesjs/fes' {
|
||||
interface PluginBuildConfig {
|
||||
globalCSS?: 'beforeImports' | 'afterImports';
|
||||
alias?: Record<string, string>;
|
||||
console?: {
|
||||
version?: boolean;
|
||||
};
|
||||
autoprefixer?: {
|
||||
/** environment for `Browserslist` */
|
||||
env?: string;
|
||||
@ -86,10 +89,10 @@ declare module '@fesjs/fes' {
|
||||
dynamicImport?: boolean;
|
||||
inlineLimit?: number;
|
||||
mock?:
|
||||
| boolean
|
||||
| {
|
||||
prefix?: string;
|
||||
};
|
||||
| boolean
|
||||
| {
|
||||
prefix?: string;
|
||||
};
|
||||
mountElementId?: string;
|
||||
plugins?: string[];
|
||||
presets?: string[];
|
||||
|
@ -8,6 +8,9 @@ export default defineBuildConfig({
|
||||
define: {
|
||||
__DEV__: false,
|
||||
},
|
||||
console: {
|
||||
version: true,
|
||||
},
|
||||
html: {
|
||||
title: '海贼王',
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user