Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Resolve imports relative to the sass entry point.
Browse files Browse the repository at this point in the history
  • Loading branch information
notlee committed Apr 17, 2020
1 parent 65006d3 commit 044b02c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/tasks/build-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ module.exports = function buildSass(config) {
// Build Sass
let result = '';
try {
result = execa.sync(ftSass, sassArguments, { input: sassData });
result = execa.sync(ftSass, sassArguments, {
input: sassData,
cwd: path.dirname(sassFile)
});
// Output Sass debug logs and warnings
if (result.stderr) {
log.secondary(result.stderr);
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/o-test/demos/src/demo-scss/demo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import '../../../main';
11 changes: 11 additions & 0 deletions test/unit/tasks/build-sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,15 @@ describe('Build Sass', function () {
proclaim.include(error.message, invalidSass);
});
});

it('should resolve imports relative to the sass entry point', function () {
return build({
sass: 'demos/src/demo-scss/demo.scss'
})
.then(function (result) {
const builtCss = fs.readFileSync('build/main.css', 'utf8');
proclaim.include(builtCss, 'div {\n color: blue;\n}\n');
proclaim.include(result, 'div {\n color: blue;\n}\n');
});
});
});

0 comments on commit 044b02c

Please sign in to comment.