Fixed a problem with the build task in gulpfile.js that would omit the css @font-face rule.

This commit is contained in:
jordanbrauer 2016-10-04 13:36:54 -05:00
parent fb8dbeed3d
commit 81dcaee687

View File

@ -10,14 +10,20 @@ var gulp = require('gulp'), // task runner/manager (even
rename = require('gulp-rename'), // allows us to rename files (adding prefixes and suffixes is the main use here). rename = require('gulp-rename'), // allows us to rename files (adding prefixes and suffixes is the main use here).
autoprefixer = require('gulp-autoprefixer'), // great for catching those annoying vendor prefixes on css attributets and values. autoprefixer = require('gulp-autoprefixer'), // great for catching those annoying vendor prefixes on css attributets and values.
minify = require('gulp-cssnano'), // minify our compiled css. sass can do this natively (kind of), so this is used in conjunction with gulp-sass. minify = require('gulp-cssnano'), // minify our compiled css. sass can do this natively (kind of), so this is used in conjunction with gulp-sass.
merge = require('merge-stream'), // used to merge multiple streams into a single stream for node.
runseq = require('run-sequence'), // runs a sequence of gulp tasks. this is used because gulp.run is deprecated.
del = require('del'); // del is used to cleanup cache and build files. del = require('del'); // del is used to cleanup cache and build files.
/* /*
* Variables ==================================== * Variables ====================================
* | silly, long, reused paths/dirs go here if needed. * | silly, long, reused paths/dirs go here if needed.
*/ */
var $supported = [
'last 2 versions',
'safari >= 8',
'ie >= 10',
'ff >= 20',
'ios 6',
'android 4'
];
/* /*
* Gulp Tasks =================================== * Gulp Tasks ===================================
@ -28,21 +34,36 @@ var gulp = require('gulp'), // task runner/manager (even
* Build CSS Task ------------------------------- * Build CSS Task -------------------------------
* | $ gulp build * | $ gulp build
* | * |
* | compiles scss into css, * | 1. compiles scss into css,
* | autoprefix necessary css attributes/values, * | 2. autoprefix necessary css attributes/values,
* | minify prefixed css, * | 3. place compiled file into ./css directory
* | rename minified file with a '.min' suffix, * | 4. minify prefixed css,
* | place into ./css directory * | 5. rename minified file with a '.min' suffix,
* | 6. place minified file into ./css directory
* | 7. notify on task completion
*/ */
gulp.task('build', function() { gulp.task('build', function() {
return gulp.src('./sass/**/*.scss') return gulp.src('./sass/**/*.scss')
.pipe(sass()) .pipe(sass({ // 1.
.pipe(gulp.dest('./css')) outputStyle: 'expanded'
.pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false })) }).on('error', sass.logError))
.pipe(minify()) .pipe(autoprefixer({ // 2.
.pipe(rename({ suffix: '.min' })) browsers: $supported,
.pipe(gulp.dest('./css')) add: true,
.pipe(notify({ onLast: true, message: 'build task complete' })); cascade: false
}))
.pipe(gulp.dest('./css')) // 3.
.pipe(minify({ // 4.
discardUnused: { fontFace: false }
}))
.pipe(rename({ // 5.
suffix: '.min'
}))
.pipe(gulp.dest('./css')) // 6.
.pipe(notify({ // 7.
onLast: true,
message: 'build task complete!'
}));
}); });
/* /*