Skip to content

Commit

Permalink
chore(sass): abstract sass-importer from compiler-sass script (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
emoralesb05 authored Mar 29, 2017
1 parent 04f2ba2 commit bb5a203
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 2 additions & 8 deletions scripts/compile-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

var gulp = require('gulp-help')(require('gulp'));
var sass = require('gulp-sass');
var path = require("path");
var sourcemaps = require('gulp-sourcemaps');
var config = require('../build.conf');
var sassImporter = require('./sass-importer');

gulp.task('compile-sass', 'Build the module styles', function() {
return gulp
.src(config.paths.styles)
//.pipe(sourcemaps.init()) // add later on when not using relative routes for node_modules scss
.pipe(sass({
errLogToConsole: true,
importer: function(url, prev, done) {
if (url.indexOf('~') === 0) {
url = 'node_modules/' + url.substring(1, url.length);
return {file: path.relative(path.dirname(prev), url)};
}
return {file: url};
}
importer: sassImporter,
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('deploy/'));
Expand Down
9 changes: 9 additions & 0 deletions scripts/sass-importer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var path = require("path");

module.exports = function sassImporter(url, prev, done) {
if (url.indexOf('~') === 0) {
url = 'node_modules/' + url.substring(1, url.length);
return {file: path.relative(path.dirname(prev), url)};
}
return {file: url};
}

0 comments on commit bb5a203

Please sign in to comment.