From bb5a203590ded227f7295fd9d07bae7853526a6f Mon Sep 17 00:00:00 2001 From: Ed Morales Date: Wed, 29 Mar 2017 15:31:20 -0700 Subject: [PATCH] chore(sass): abstract sass-importer from compiler-sass script (#456) --- scripts/compile-sass.js | 10 ++-------- scripts/sass-importer.js | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 scripts/sass-importer.js diff --git a/scripts/compile-sass.js b/scripts/compile-sass.js index d6dd9b7cd8..8a42c2efeb 100644 --- a/scripts/compile-sass.js +++ b/scripts/compile-sass.js @@ -2,9 +2,9 @@ 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 @@ -12,13 +12,7 @@ gulp.task('compile-sass', 'Build the module styles', function() { //.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/')); diff --git a/scripts/sass-importer.js b/scripts/sass-importer.js new file mode 100644 index 0000000000..1cc60b9d05 --- /dev/null +++ b/scripts/sass-importer.js @@ -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}; +} \ No newline at end of file