Skip to content

Commit e52f687

Browse files
author
Kyle Andrews
committed
Closes #4 - adds support for including SCSS import paths
1 parent 9c436f8 commit e52f687

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- updated purgeCSS to v2 [#3](https://github.com/codewithkyle/cssmonster/issues/3)
13+
- ability to include node-sass paths [#4](https://github.com/codewithkyle/cssmonster/issues/4)
14+
1015
## [0.1.1] - 2020-01-18
1116

1217
### Fixed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
content: ["**/*.html"],
5757
},
5858
blacklist: [],
59+
include: [], // Paths that will be included while compiling the SCSS
5960
};
6061
```
6162

cssmonster.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class CSSMonster {
5757
content: [path.resolve(cwd, "**/*.html")],
5858
},
5959
blacklist: [],
60+
include: [],
6061
};
6162
this.run();
6263
}
@@ -165,6 +166,19 @@ class CSSMonster {
165166
this.config.purge = false;
166167
}
167168

169+
/** Included paths */
170+
if (typeof this.config.include !== "undefined") {
171+
if (typeof config.include === "string") {
172+
this.config.include = [path.resolve(cwd, config.include)];
173+
} else if (Array.isArray(config.include)) {
174+
this.config.include = [];
175+
for (let i = 0; i < config.include.length; i++) {
176+
const filePath = path.resolve(cwd, config.include[i]);
177+
this.config.include.push(filePath);
178+
}
179+
}
180+
}
181+
168182
resolve();
169183
});
170184
}
@@ -232,7 +246,7 @@ class CSSMonster {
232246
if (fs.existsSync(`${this.tempDir}/normalize.css`)) {
233247
data = fs.readFileSync(`${this.tempDir}/normalize.css`).toString();
234248
}
235-
const normalizePath = path.resolve(__dirname, "node_modules/normalize.css/normalize.css");
249+
const normalizePath = path.resolve(cwd, "node_modules/normalize.css/normalize.css");
236250
const preflightPath = path.join(__dirname, "preflight.css");
237251
data += fs.readFileSync(normalizePath).toString();
238252
data += fs.readFileSync(preflightPath).toString();
@@ -274,6 +288,7 @@ class CSSMonster {
274288
{
275289
file: file,
276290
outputStyle: "expanded",
291+
includePaths: this.config.include,
277292
},
278293
(error, result) => {
279294
if (error) {

0 commit comments

Comments
 (0)