File tree Expand file tree Collapse file tree
packages/theme-mobile/build Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- /**
2- * 打包 src 目录到 dist 目录
3- */
41const gulp = require ( 'gulp' )
52const less = require ( 'gulp-less' )
63const 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 ) )
You can’t perform that action at this time.
0 commit comments