Skip to content

Commit

Permalink
chore(other): print project information in console
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Sep 2, 2024
1 parent 0651b64 commit d9cf87a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { setupUnocss } from './unocss';
import { setupUnPluginIcon } from './unplugin-icon';
import { setupElegantRouter } from './router';
import { setupHtmlPlugin } from './html';
import { setupProjectInfo } from './info';

export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
const plugins: PluginOption = [
Expand All @@ -17,7 +18,8 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
setupElegantRouter(),
Inspect(),
removeConsole(),
setupHtmlPlugin(buildTime)
setupHtmlPlugin(buildTime),
setupProjectInfo()
];
return plugins;
}
23 changes: 23 additions & 0 deletions build/plugins/info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Plugin } from 'vite';
import gradientString from 'gradient-string';
import boxen, { type Options as BoxenOptions } from 'boxen';

const welcomeMessage = gradientString('#646cff', 'magenta').multiline(
`您好! 欢迎使用 react-soybean 开源项目\n我们为您精心准备了精美的保姆级文档\nhttps://react-soybean-docs.pages.dev/index-cn?theme=dark`
);

const boxenOptions: BoxenOptions = {
padding: 0.5,
borderColor: '#646cff',
borderStyle: 'round'
};

export function setupProjectInfo(): Plugin {
return {
name: 'vite:buildInfo',

buildStart() {
console.log(boxen(welcomeMessage, boxenOptions));
}
};
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@soybeanjs/eslint-config": "1.4.0",
"@svgr/core": "8.1.0",
"@svgr/plugin-jsx": "8.1.0",
"@types/gradient-string": "1.1.6",
"@types/node": "22.5.0",
"@types/nprogress": "0.2.3",
"@types/react": "18.3.4",
Expand All @@ -101,11 +102,13 @@
"@unocss/transformer-variant-group": "0.62.3",
"@unocss/vite": "0.62.3",
"@vitejs/plugin-react": "4.3.1",
"boxen": "8.0.1",
"eslint": "9.9.1",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.11",
"json5": "^2.2.3",
"gradient-string": "2.0.2",
"json5": "2.2.3",
"lint-staged": "15.2.9",
"sass": "1.77.8",
"simple-git-hooks": "2.11.1",
Expand Down
66 changes: 65 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9cf87a

Please sign in to comment.