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

Commit

Permalink
Allow Sass sourcemaps to be disabled.
Browse files Browse the repository at this point in the history
For example, whilst running compilation tests:
#780
  • Loading branch information
notlee committed May 15, 2020
1 parent a5e4129 commit e86570b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/tasks/build-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ module.exports = function buildSass(config) {
if (sassFile) {
const destFolder = config.buildFolder || files.getBuildFolderPath(cwd);
const dest = config.buildCss || 'main.css';
const useSourceMaps = config.sourcemaps || true;
const useSourceMaps = typeof config.sourcemaps === 'boolean' ?
config.sourcemaps :
true;
const sassData = getSassData(sassFile, {
brand: config.brand,
sassPrefix: config.sassPrefix,
Expand Down
23 changes: 23 additions & 0 deletions test/unit/tasks/build-sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,27 @@ describe('Build Sass', function () {
proclaim.include(result, 'div {\n color: blue;\n}');
});
});

it('should output source maps by default', function () {
return build({
sass: 'demos/src/demo-scss/demo.scss'
})
.then(function (result) {
const builtCss = fs.readFileSync('build/main.css', 'utf8');
proclaim.include(builtCss, '/*# sourceMappingURL=');
proclaim.include(result, '/*# sourceMappingURL=');
});
});

it('should not not output a source map when the sourcemaps option is false', function () {
return build({
sass: 'demos/src/demo-scss/demo.scss',
sourcemaps: false
})
.then(function (result) {
const builtCss = fs.readFileSync('build/main.css', 'utf8');
proclaim.doesNotInclude(builtCss, '/*# sourceMappingURL=');
proclaim.doesNotInclude(result, '/*# sourceMappingURL=');
});
});
});

0 comments on commit e86570b

Please sign in to comment.