mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-05 11:18:54 +08:00
feat: 添加 console 配置,支持输出 version (#263)
This commit is contained in:
parent
e957e6b365
commit
4c9941503e
@ -93,6 +93,22 @@ export default {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### console
|
||||||
|
|
||||||
|
- 类型: `object`
|
||||||
|
- 默认值:`{}`
|
||||||
|
- 详情:
|
||||||
|
用于控制应用启动的时候在 console 中打印的信息,目前仅支持 version
|
||||||
|
- 示例:
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
console: {
|
||||||
|
version: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### define
|
### define
|
||||||
|
|
||||||
- 类型: `object`
|
- 类型: `object`
|
||||||
|
@ -16,6 +16,7 @@ export default function () {
|
|||||||
require.resolve('./plugins/features/alias'),
|
require.resolve('./plugins/features/alias'),
|
||||||
require.resolve('./plugins/features/autoprefixer'),
|
require.resolve('./plugins/features/autoprefixer'),
|
||||||
require.resolve('./plugins/features/define'),
|
require.resolve('./plugins/features/define'),
|
||||||
|
require.resolve('./plugins/features/console'),
|
||||||
require.resolve('./plugins/features/dynamicImport'),
|
require.resolve('./plugins/features/dynamicImport'),
|
||||||
require.resolve('./plugins/features/globalCSS'),
|
require.resolve('./plugins/features/globalCSS'),
|
||||||
require.resolve('./plugins/features/inlineLimit'),
|
require.resolve('./plugins/features/inlineLimit'),
|
||||||
|
@ -12,6 +12,8 @@ import DefaultContainer from './defaultContainer.vue';
|
|||||||
|
|
||||||
{{{ entryCodeAhead }}}
|
{{{ entryCodeAhead }}}
|
||||||
|
|
||||||
|
{{{ CONSOLE }}}
|
||||||
|
|
||||||
const renderClient = (opts = {}) => {
|
const renderClient = (opts = {}) => {
|
||||||
const { plugin, routes, rootElement } = opts;
|
const { plugin, routes, rootElement } = opts;
|
||||||
const rootContainer = plugin.applyPlugins({
|
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) {
|
export default function (api) {
|
||||||
const {
|
const {
|
||||||
utils: { Mustache },
|
utils: { Mustache },
|
||||||
@ -24,6 +33,7 @@ export default function (api) {
|
|||||||
path: 'fes.js',
|
path: 'fes.js',
|
||||||
content: Mustache.render(fesTpl, {
|
content: Mustache.render(fesTpl, {
|
||||||
enableTitle: api.config.title !== false,
|
enableTitle: api.config.title !== false,
|
||||||
|
CONSOLE: getConsoleInfo(api.config, api.pkg),
|
||||||
defaultTitle: api.config.title || 'fes.js',
|
defaultTitle: api.config.title || 'fes.js',
|
||||||
runtimePath,
|
runtimePath,
|
||||||
rootElement: `#${api.config.mountElementId || 'app'}`,
|
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');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
9
packages/fes-preset-built-in/types.d.ts
vendored
9
packages/fes-preset-built-in/types.d.ts
vendored
@ -1,8 +1,8 @@
|
|||||||
import { Component, DefineComponent, Component, App } from 'vue';
|
import type { App, Component, DefineComponent } from 'vue';
|
||||||
import { RouteRecordRaw, Router, RouterHistory, createMemoryHistory, createWebHashHistory, createWebHistory } from 'vue-router';
|
import type { createMemoryHistory, createWebHashHistory, createWebHistory, Router, RouteRecordRaw, RouterHistory } from 'vue-router';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Plugin } from '@fesjs/runtime';
|
import type { Plugin } from '@fesjs/runtime';
|
||||||
|
|
||||||
interface BeforeRenderConfig {
|
interface BeforeRenderConfig {
|
||||||
loading: Component;
|
loading: Component;
|
||||||
@ -44,6 +44,9 @@ declare module '@fesjs/fes' {
|
|||||||
interface PluginBuildConfig {
|
interface PluginBuildConfig {
|
||||||
globalCSS?: 'beforeImports' | 'afterImports';
|
globalCSS?: 'beforeImports' | 'afterImports';
|
||||||
alias?: Record<string, string>;
|
alias?: Record<string, string>;
|
||||||
|
console?: {
|
||||||
|
version?: boolean;
|
||||||
|
};
|
||||||
autoprefixer?: {
|
autoprefixer?: {
|
||||||
/** environment for `Browserslist` */
|
/** environment for `Browserslist` */
|
||||||
env?: string;
|
env?: string;
|
||||||
|
@ -8,6 +8,9 @@ export default defineBuildConfig({
|
|||||||
define: {
|
define: {
|
||||||
__DEV__: false,
|
__DEV__: false,
|
||||||
},
|
},
|
||||||
|
console: {
|
||||||
|
version: true,
|
||||||
|
},
|
||||||
html: {
|
html: {
|
||||||
title: '海贼王',
|
title: '海贼王',
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user