Skip to content

Commit

Permalink
fix: use absWorkingDir as root if provided. fixes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Dec 29, 2022
1 parent 2703569 commit 688a904
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 688a904

Please sign in to comment.