fix:修改github actions打包报错问题

This commit is contained in:
zyronon
2025-08-10 02:00:04 +08:00
parent 36af50da1c
commit 62d72c360a

View File

@@ -16,86 +16,87 @@ function pathResolve(dir: string) {
const lifecycle = process.env.npm_lifecycle_event;
async function getConfig(): Promise<Partial<UserConfig>> {
const latestCommitHash = await new Promise<string>((resolve) => {
return getLastCommit((err, commit) => (err ? 'unknown' : resolve(commit.shortHash)))
})
return {
plugins: [
VueMacros({
plugins: {
vue: Vue(),
vueJsx: VueJsx(), // 如果需要
},
}),
UnoCSS(),
ElementPlus(),
lifecycle === 'report' ?
visualizer({
gzipSize: true,
brotliSize: true,
emitFile: false,
filename: "report.html", //分析图生成的文件名
open: true //如果存在本地服务端口,将在打包后自动展示
}) : null,
SlidePlugin(),
importToCDN({
modules: [
{
name: 'vue',
var: 'Vue',
path: `https://cdn.jsdelivr.net/npm/vue@3.5.14/dist/vue.global.prod.min.js`
// https://vitejs.dev/config/
export default defineConfig(() => {
return new Promise(resolve => {
let latestCommitHash = ''
getLastCommit((err, commit) => {
if (!err) latestCommitHash = commit.shortHash
})
resolve({
plugins: [
VueMacros({
plugins: {
vue: Vue(),
vueJsx: VueJsx(), // 如果需要
},
{
name: 'vue-router',
var: 'VueRouter',
path: `https://cdn.jsdelivr.net/npm/vue-router@4.5.1/dist/vue-router.global.prod.min.js`
},
{
name: 'axios',
var: 'axios',
path: 'https://cdn.jsdelivr.net/npm/axios@1.9.0/dist/axios.min.js'
},
]
})
],
define: {
LATEST_COMMIT_HASH: JSON.stringify(latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')),
},
//默认是'',导致只能在一级域名下使用。
base: './',
resolve: {
alias: {
"@": pathResolve("src"),
}),
UnoCSS(),
ElementPlus(),
lifecycle === 'report' ?
visualizer({
gzipSize: true,
brotliSize: true,
emitFile: false,
filename: "report.html", //分析图生成的文件名
open: true //如果存在本地服务端口,将在打包后自动展示
}) : null,
SlidePlugin(),
importToCDN({
modules: [
{
name: 'vue',
var: 'Vue',
path: `https://cdn.jsdelivr.net/npm/vue@3.5.14/dist/vue.global.prod.min.js`
},
{
name: 'vue-router',
var: 'VueRouter',
path: `https://cdn.jsdelivr.net/npm/vue-router@4.5.1/dist/vue-router.global.prod.min.js`
},
{
name: 'axios',
var: 'axios',
path: 'https://cdn.jsdelivr.net/npm/axios@1.9.0/dist/axios.min.js'
},
]
})
],
define: {
LATEST_COMMIT_HASH: JSON.stringify(latestCommitHash + (process.env.NODE_ENV === 'production' ? '' : ' (dev)')),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
// build: {
// rollupOptions: {
// external: ['axios'],// 使用全局的 axios。因为百度翻译库内部用了0.19版本的axios会被打包到代码里面
// }
// },
css: {
preprocessorOptions: {
scss: {
//解决 sass 控制台出现 Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0 的问题
api: "modern-compiler" // or 'modern'
//默认是'',导致只能在一级域名下使用。
base: './',
resolve: {
alias: {
"@": pathResolve("src"),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
// build: {
// rollupOptions: {
// external: ['axios'],// 使用全局的 axios。因为百度翻译库内部用了0.19版本的axios会被打包到代码里面
// }
// },
css: {
preprocessorOptions: {
scss: {
//解决 sass 控制台出现 Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0 的问题
api: "modern-compiler" // or 'modern'
}
}
},
server: {
port: 3000,
open: false,
host: '0.0.0.0',
fs: {
strict: false,
},
proxy: {
'/baidu': 'https://api.fanyi.baidu.com/api/trans/vip/translate'
}
}
},
server: {
port: 3000,
open: false,
host: '0.0.0.0',
fs: {
strict: false,
},
proxy: {
'/baidu': 'https://api.fanyi.baidu.com/api/trans/vip/translate'
}
}
}
}
// https://vitejs.dev/config/
export default defineConfig(getConfig as any)
})
})
})