vben
3 months ago
16 changed files with 156 additions and 74 deletions
-
13.github/semantic.yml
-
1internal/node-utils/package.json
-
10internal/node-utils/src/date.ts
-
10internal/node-utils/src/index.ts
-
1internal/vite-config/src/config/application.ts
-
4internal/vite-config/src/plugins/extra-app-config.ts
-
7internal/vite-config/src/plugins/index.ts
-
76internal/vite-config/src/plugins/license.ts
-
2internal/vite-config/src/typing.ts
-
5package.json
-
3packages/@core/uikit/menu-ui/src/components/normal-menu/normal-menu.vue
-
39packages/@core/uikit/tabs-ui/src/components/chrome-tabs/chrome-tabs.scss
-
23packages/@core/uikit/tabs-ui/src/components/chrome-tabs/tab-background.vue
-
5packages/@core/uikit/tabs-ui/src/components/chrome-tabs/tab.vue
-
8packages/@core/uikit/tabs-ui/src/components/chrome-tabs/tabs.vue
-
23pnpm-lock.yaml
@ -0,0 +1,13 @@ |
|||
titleAndCommits: true |
|||
types: |
|||
- feat |
|||
- fix |
|||
- docs |
|||
- chore |
|||
- style |
|||
- refactor |
|||
- perf |
|||
- test |
|||
- build |
|||
- ci |
|||
- revert |
@ -0,0 +1,10 @@ |
|||
import dayjs from 'dayjs'; |
|||
import timezone from 'dayjs/plugin/timezone'; |
|||
import utc from 'dayjs/plugin/utc'; |
|||
|
|||
dayjs.extend(utc); |
|||
dayjs.extend(timezone); |
|||
|
|||
const dateUtil = dayjs().tz('Asia/Shanghai'); |
|||
|
|||
export { dateUtil }; |
@ -0,0 +1,76 @@ |
|||
import type { |
|||
NormalizedOutputOptions, |
|||
OutputAsset, |
|||
OutputBundle, |
|||
OutputChunk, |
|||
} from 'rollup'; |
|||
import type { PluginOption } from 'vite'; |
|||
|
|||
import { EOL } from 'node:os'; |
|||
|
|||
import { dateUtil, readPackageJSON } from '@vben/node-utils'; |
|||
|
|||
/** |
|||
* 用于将配置文件抽离出来并注入到项目中 |
|||
* @returns |
|||
*/ |
|||
|
|||
async function viteLicensePlugin( |
|||
root = process.cwd(), |
|||
): Promise<PluginOption | undefined> { |
|||
const { |
|||
description = '', |
|||
homepage = '', |
|||
version = '', |
|||
} = await readPackageJSON(root); |
|||
|
|||
return { |
|||
apply: 'build', |
|||
enforce: 'post', |
|||
generateBundle: { |
|||
handler: (_options: NormalizedOutputOptions, bundle: OutputBundle) => { |
|||
const date = dateUtil.format('YYYY-MM-DD '); |
|||
|
|||
const copyrightText = `/*!
|
|||
* Vben Admin Pro |
|||
* Version: ${version} |
|||
* Author: vben |
|||
* Copyright (C) 2024 Vben |
|||
* License: MIT License |
|||
* Description: ${description} |
|||
* Date Created: ${date} |
|||
* Homepage: ${homepage} |
|||
* Contact: ann.vben@gmail.com |
|||
*/ |
|||
`.trim();
|
|||
|
|||
for (const [, fileContent] of Object.entries(bundle)) { |
|||
if ( |
|||
fileContent.type === 'asset' || |
|||
(fileContent.type === 'chunk' && fileContent.isEntry) |
|||
) { |
|||
const chunkContent = fileContent as OutputChunk; |
|||
const assetContent = fileContent as OutputAsset; |
|||
// 插入版权信息
|
|||
const content = |
|||
typeof assetContent.source === 'string' |
|||
? assetContent.source |
|||
: chunkContent.code; |
|||
const updatedContent = `${copyrightText}${EOL}${content}`; |
|||
|
|||
// 更新bundle
|
|||
if (assetContent.source === undefined) { |
|||
(fileContent as OutputChunk).code = updatedContent; |
|||
} else { |
|||
(fileContent as OutputAsset).source = updatedContent; |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
order: 'post', |
|||
}, |
|||
name: 'vite:license', |
|||
}; |
|||
} |
|||
|
|||
export { viteLicensePlugin }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue