Skip to content

Commit 1b8c667

Browse files
Rewrote preprocessor importer to comply with new dart sass (#34)
1 parent 059660d commit 1b8c667

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as esbuild from "esbuild";
22
import * as path from "path";
33
import * as fs from 'fs';
44
import * as crypto from "crypto";
5+
import { pathToFileURL } from 'url';
56

67
import ts from "typescript";
78

@@ -271,19 +272,19 @@ const vuePlugin = (opts: Options = {}) => <esbuild.Plugin>{
271272
includePaths: [
272273
path.dirname(args.path)
273274
],
274-
importer: [
275-
(url: string) => {
275+
importer: {
276+
findFileUrl(url: string) {
276277
const projectRoot = process.env.npm_config_local_prefix || process.cwd()
277-
const modulePath = path.join(projectRoot, "node_modules", url);
278+
const modulePath = path.join(projectRoot, "node_modules", url)
278279

279-
if (fs.existsSync(modulePath)) {
280-
return { file: modulePath }
281-
}
280+
if (fs.existsSync(modulePath)) return pathToFileURL(modulePath)
281+
282+
const replacedPath = replaceRules(url);
283+
if (fs.existsSync(replacedPath)) return pathToFileURL(replacedPath)
282284

283285
return null
284286
},
285-
(url: string) => ({ file: replaceRules(url) })
286-
]
287+
},
287288
}, opts.preprocessorOptions),
288289
scoped: style.scoped,
289290
});

0 commit comments

Comments
 (0)