Skip to content

Commit 0f549c8

Browse files
committed
♻️ refactor: code
1 parent 0a64424 commit 0f549c8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

layouts/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
*/
44

55
const webpackBarName = 'vue-admin-better'
6-
const webpackBanner =
7-
' build: vue-admin-better \n vue-admin-better.com \n https://gitee.com/chu1204505056/vue-admin-better \n time: '
6+
const webpackBanner = (time) =>
7+
`/*!
8+
* vue-admin-better
9+
* GitHub: https://github.com/zxwk1998/vue-admin-better
10+
* Gitee: https://gitee.com/chu1204505056/vue-admin-better
11+
*
12+
* 版权所有 (c) 2025 vue-admin-better
13+
* 本项目使用 MIT 许可证
14+
* 构建时间: ${time}
15+
*/`
816

917
/**
1018
* @description 在控制台打印项目信息
@@ -48,4 +56,4 @@ module.exports = {
4856
webpackBarName,
4957
webpackBanner,
5058
donationConsole,
51-
}
59+
}

rspack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
const path = require('path')
2-
const { Configuration, DefinePlugin } = require('@rspack/core')
2+
const { Configuration, DefinePlugin, BannerPlugin } = require('@rspack/core')
33
const HtmlRspackPlugin = require('html-rspack-plugin')
44
const { VueLoaderPlugin } = require('vue-loader')
55
const { publicPath, assetsDir, outputDir, title, devPort } = require('./src/config')
66
const dayjs = require('dayjs')
77
const time = dayjs().format('YYYY-M-D HH:mm:ss')
88
const fs = require('fs-extra')
9+
const { webpackBanner } = require('./layouts')
910

1011
// 设置环境变量
1112
process.env.VUE_APP_TITLE = title || 'vue-admin-better'
@@ -168,6 +169,11 @@ module.exports = {
168169
}
169170
: false,
170171
}),
172+
// 添加版权信息到打包文件头部
173+
new BannerPlugin({
174+
banner: webpackBanner + time,
175+
entryOnly: true,
176+
}),
171177
// 添加CopyPlugin功能,将public目录下除index.html外的文件复制到dist目录
172178
{
173179
apply(compiler) {

0 commit comments

Comments
 (0)