Skip to content

Commit b0f9527

Browse files
committed
Merge branch 'release/2.0.1'
2 parents bd61703 + a6620b0 commit b0f9527

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-plugin-css-modules",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"main": "lib/index.js",
55
"author": "Brody McKee <[email protected]>",
66
"license": "MIT",

src/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,28 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
3131
const options: Options = info.config.options || {};
3232
logger.log(`options: ${JSON.stringify(options)}`);
3333

34-
// Set environment variables, resolves #49.
34+
// Load environment variables like SASS_PATH.
3535
// TODO: Add tests for this option.
36+
const dotenvOptions = options.dotenvOptions || {};
37+
if (dotenvOptions) {
38+
dotenvOptions.path = path.resolve(
39+
directory,
40+
dotenvOptions.path || '.env',
41+
);
42+
}
3643
dotenv.config(options.dotenvOptions);
3744

45+
// Normalise SASS_PATH array to absolute paths.
46+
if (process.env.SASS_PATH) {
47+
process.env.SASS_PATH = process.env.SASS_PATH.split(path.delimiter)
48+
.map((sassPath) =>
49+
path.isAbsolute(sassPath)
50+
? sassPath
51+
: path.resolve(directory, sassPath),
52+
)
53+
.join(path.delimiter);
54+
}
55+
3856
// Add postCSS config if enabled.
3957
const postCssOptions = options.postCssOptions || {};
4058

0 commit comments

Comments
 (0)