Created
September 3, 2015 07:44
-
-
Save rkorebrits/18932bb6439b386fb4fc to your computer and use it in GitHub Desktop.
Stackoverflow #32253344
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cssTasks = function(filename) { | |
"use strict"; | |
return lazypipe() | |
.pipe(function() { | |
return gulpif((!config.env || config.env !== 'dev') && !enabled.failStyleTask, plumber()); | |
}) | |
.pipe(function() { | |
return gulpif((!config.env || config.env !== 'dev') && enabled.maps, sourcemaps.init()); | |
}) | |
.pipe(function() { | |
return gulpif('*.less', less()); | |
}) | |
.pipe(function() { | |
return gulpif('*.scss', sass({ | |
outputStyle: 'nested', // libsass doesn't support expanded yet | |
precision: 10, | |
includePaths: ['.'], | |
errLogToConsole: !enabled.failStyleTask | |
})); | |
}) | |
.pipe(concat, filename) | |
.pipe(function() { | |
return gulpif(!config.env || config.env !== 'dev', autoprefixer({ | |
browsers: [ | |
'last 2 versions', | |
'ie 8', | |
'ie 9', | |
'android 2.3', | |
'android 4', | |
'opera 12' | |
] | |
})); | |
}) | |
.pipe(function() { | |
return gulpif(!config.env || config.env !== 'dev', minifyCss({ | |
advanced: false, | |
rebase: false | |
})); | |
}) | |
.pipe(function() { | |
return gulpif((!config.env || config.env !== 'dev') && enabled.rev, rev()); | |
}) | |
.pipe(function() { | |
return gulpif((!config.env || config.env !== 'dev') && enabled.maps, sourcemaps.write('.')); | |
})(); | |
}; | |
// ### Styles | |
// `gulp styles` - Compiles, combines, and optimizes Bower CSS and project CSS. | |
// By default this task will only log a warning if a precompiler error is | |
// raised. If the `--production` flag is set: this task will fail outright. | |
gulp.task('styles', ['wiredep'], function() { | |
"use strict"; | |
var merged = merge(); | |
manifest.forEachDependency('css', function(dep) { | |
var cssTasksInstance = cssTasks(dep.name); | |
if (!enabled.failStyleTask) { | |
cssTasksInstance.on('error', function(err) { | |
console.error(err.message); | |
this.emit('end'); | |
}); | |
} | |
merged.add(gulp.src(dep.globs, {base: 'styles'}) | |
.pipe(cssTasksInstance)); | |
}); | |
return merged | |
.pipe(writeToManifest('styles')); | |
}); | |
// ### Fonts | |
// `gulp fonts` - Grabs all the fonts and outputs them in a flattened directory | |
// structure. See: https://github.com/armed/gulp-flatten | |
gulp.task('fonts', function() { | |
"use strict"; | |
return gulp.src(globs.fonts) | |
.pipe(flatten()) | |
.pipe(gulp.dest(path.dist + 'fonts')) | |
.pipe(browserSync.stream()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment