From 6bc002d73bf30989654154d9d06e0c32295c4b53 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:30:58 +0000 Subject: [PATCH 1/3] Initial plan From 1befa94ccc8842cc7ad65f89a9bb977920b96e94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:44:07 +0000 Subject: [PATCH 2/3] fix: normalize absolute Windows paths in SCSS @use/@import/@forward for Sass compatibility On Windows, drive letters like C:/ in @use paths are misinterpreted as URL schemes by Dart Sass, causing 'Can't find stylesheet to import' errors. Extract the directory into loadPaths and rewrite to just the module name. Co-authored-by: Simon-He95 <57086651+Simon-He95@users.noreply.github.com> Agent-Logs-Url: https://github.com/Simon-He95/transformToTailwindcss/sessions/3d36196a-6917-47a4-88cd-ac5d5e21ffa3 --- src/sassCompiler.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sassCompiler.ts b/src/sassCompiler.ts index ef5578b..a16bf44 100644 --- a/src/sassCompiler.ts +++ b/src/sassCompiler.ts @@ -184,6 +184,21 @@ export async function sassCompiler( } } + // Normalize absolute Windows paths in @use/@import/@forward directives. + // On Windows, drive letters like C:/ are misinterpreted as URL schemes by + // Sass, so we extract the directory into loadPaths and rewrite the import + // to just the module name. + const winAbsPathRegex = /@(use|import|forward)\s+(['"])([A-Za-z]:[/\\][^'"]+)\2/g + result = result.replace(winAbsPathRegex, (match, kw, quote, absPath) => { + const nativePath = absPath.replace(/\//g, path.sep) + const dir = path.dirname(nativePath) + const basename = path.basename(nativePath) + if (!compileOptions.loadPaths.includes(dir)) { + compileOptions.loadPaths.push(dir) + } + return `@${kw} ${quote}${basename}${quote}` + }) + // 优先使用新的 compile API(如果可用),否则回退到 compileString let compiledResult: any From 79cce7d84fe2398db43b33528102d9a080120943 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:51:28 +0000 Subject: [PATCH 3/3] fix: return original CSS instead of undefined on Sass compilation errors Align error handling with transformToUnoCSS PR #70: when Sass compilation fails, return the original CSS input instead of undefined so that transformVue can still process the style block. Co-authored-by: Simon-He95 <57086651+Simon-He95@users.noreply.github.com> Agent-Logs-Url: https://github.com/Simon-He95/transformToTailwindcss/sessions/8c2955bd-691e-4e84-b24b-e78cc31b49ad --- src/sassCompiler.ts | 2 +- test/sassCompiler.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sassCompiler.ts b/src/sassCompiler.ts index a16bf44..baee1b4 100644 --- a/src/sassCompiler.ts +++ b/src/sassCompiler.ts @@ -264,6 +264,6 @@ export async function sassCompiler( console.error( `Error:\n transform-to-unocss(sassCompiler) ${error.toString()}`, ) - return undefined + return css } } diff --git a/test/sassCompiler.test.ts b/test/sassCompiler.test.ts index 19926f7..113fc7f 100644 --- a/test/sassCompiler.test.ts +++ b/test/sassCompiler.test.ts @@ -261,8 +261,8 @@ describe('sassCompiler', () => { undefined, true, ) - // Should not throw, but return undefined and log error - expect(result).toBeUndefined() + // Should not throw, but return the original CSS and log error + expect(result).toBe(css) }) })