From 5f5fa66a95e664a5d227df1093cb133bcb8534d9 Mon Sep 17 00:00:00 2001 From: Martina Jonsson Date: Fri, 26 Sep 2025 15:19:33 +0200 Subject: [PATCH] Rewrote preprocessor importer to comply with new dart sass --- src/index.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index b261716..e02a933 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import * as esbuild from "esbuild"; import * as path from "path"; import * as fs from 'fs'; import * as crypto from "crypto"; +import { pathToFileURL } from 'url'; import ts from "typescript"; @@ -271,19 +272,19 @@ const vuePlugin = (opts: Options = {}) => { includePaths: [ path.dirname(args.path) ], - importer: [ - (url: string) => { + importer: { + findFileUrl(url: string) { const projectRoot = process.env.npm_config_local_prefix || process.cwd() - const modulePath = path.join(projectRoot, "node_modules", url); + const modulePath = path.join(projectRoot, "node_modules", url) - if (fs.existsSync(modulePath)) { - return { file: modulePath } - } + if (fs.existsSync(modulePath)) return pathToFileURL(modulePath) + + const replacedPath = replaceRules(url); + if (fs.existsSync(replacedPath)) return pathToFileURL(replacedPath) return null }, - (url: string) => ({ file: replaceRules(url) }) - ] + }, }, opts.preprocessorOptions), scoped: style.scoped, });