Skip to content

Commit 6b1f704

Browse files
committed
fix: 修复git-actions流水线报错问题
1 parent 1006330 commit 6b1f704

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

packages/theme-mobile/build/gulp-dist.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* 打包 src 目录到 dist 目录
3-
*/
41
const gulp = require('gulp')
52
const less = require('gulp-less')
63
const cssmin = require('gulp-clean-css')
@@ -44,6 +41,16 @@ const VueThemeResolver = {
4441
function(match, importPath) {
4542
const resolved = resolveVueTheme(importPath)
4643
if (resolved) {
44+
// 关键修复:如果是 .css 文件,直接内联内容,彻底绕过 less 的路径解析
45+
// pnpm store 路径中的 + 号会被 less URL 解码成空格,导致绝对路径失效
46+
if (resolved.endsWith('.css')) {
47+
try {
48+
return fs.readFileSync(resolved, 'utf-8')
49+
} catch (e) {
50+
console.warn('Warning: Cannot read ' + resolved, e.message)
51+
return match
52+
}
53+
}
4754
return '@import "' + resolved + '"'
4855
}
4956
console.warn('Warning: Cannot resolve @opentiny/vue-theme/' + importPath)
@@ -62,7 +69,6 @@ function mergeIndexLess() {
6269
throw new Error(`index.less not found at ${indexLessPath}`)
6370
}
6471

65-
// 使用绝对路径匹配,避免 fast-glob 的 cwd 解析差异
6672
const fileList = fg.sync(path.resolve(__dirname, '../src/*/index.less'))
6773
const importStr = fileList
6874
.map((filePath) => path.relative(path.dirname(indexLessPath), filePath))

0 commit comments

Comments
 (0)