Skip to content

Commit 4f77984

Browse files
committed
global root directory for all require calls
1 parent b7d2918 commit 4f77984

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import LocalByDefault from 'postcss-modules-local-by-default';
99
import Scope from 'postcss-modules-scope';
1010
import Parser from './parser';
1111

12+
const defaultRoot = process.cwd();
1213
const tokensByFile = {};
1314
let plugins = [LocalByDefault, ExtractImports, Scope];
14-
let rootDir;
15+
let root = defaultRoot;
1516

1617
/**
1718
* @param {string} sourceString The file content
@@ -29,7 +30,6 @@ function load(sourceString, sourcePath, trace, pathFetcher) {
2930
}
3031

3132
hook(filename => {
32-
const root = rootDir || dirname(filename);
3333
let importNr = 0;
3434

3535
const fetch = (_newPath, _relativeTo, _trace) => {
@@ -67,7 +67,7 @@ export default function configure(opts = {}) {
6767
? customPlugins
6868
: [LocalByDefault, ExtractImports, Scope];
6969

70-
if (opts.root && typeof opts.root === 'string') {
71-
rootDir = opts.root;
72-
}
70+
root = opts.root && typeof opts.root === 'string'
71+
? opts.root
72+
: defaultRoot;
7373
}

0 commit comments

Comments
 (0)