From 688a90452122446811144168ef444243203ebac1 Mon Sep 17 00:00:00 2001 From: shellscape Date: Thu, 29 Dec 2022 10:23:20 -0500 Subject: [PATCH] fix: use absWorkingDir as root if provided. fixes #114 --- src/plugin.ts | 9 +++++---- src/utils.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 85d20af..d55bc40 100755 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -20,10 +20,6 @@ export function sassPlugin(options: SassPluginOptions = {}): Plugin { if (options.includePaths) { console.log(`'includePaths' option is deprecated, please use 'loadPaths' instead`) } - options.loadPaths = Array.from(new Set([ - ...options.loadPaths || modulesPaths(), - ...options.includePaths || [] - ])) const type = options.type ?? 'css' @@ -37,6 +33,11 @@ export function sassPlugin(options: SassPluginOptions = {}): Plugin { name: 'sass-plugin', setup({initialOptions, onResolve, onLoad, resolve}) { + options.loadPaths = Array.from(new Set([ + ...options.loadPaths || modulesPaths(initialOptions.absWorkingDir), + ...options.includePaths || [] + ])) + const { sourcemap, watched diff --git a/src/utils.ts b/src/utils.ts index dd2d798..7834f06 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,8 +9,8 @@ import {SyncOpts} from 'resolve' export const RELATIVE_PATH = /^\.\.?\// -export function modulesPaths(): string[] { - let path = process.cwd() +export function modulesPaths(absWorkingDir?: string): string[] { + let path = absWorkingDir || process.cwd() let {root} = parse(path) let found: string[] = [] while (path !== root) {