npm i -D gulp gulp-util gulp-plumber gulp-myth gulp-csso
Created
May 22, 2014 13:18
-
-
Save MoOx/10ffc53714448fa13c79 to your computer and use it in GitHub Desktop.
Myth
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 gulp = require("gulp") | |
gulp.task("styles", require("./tasks/styles")) | |
// build | |
gulp.task("dist", [ | |
"styles" | |
]) | |
// dev tasks | |
gulp.task("default", ["dist", "watch"]) | |
gulp.task("test", ["dist"]) | |
gulp.task("watch", ["dist"], function() { | |
gulp.watch("./src/**/*.css", ["styles"]) | |
}) |
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
/** | |
* parses cli arguments as options | |
*/ | |
var options = require("minimist")(process.argv.slice(2)) | |
var defaults = { | |
debug: true, | |
plumber: true, | |
minify: false | |
} | |
// set some defaults options depending on some flags | |
if (options.production) { | |
defaults.debug = false | |
defaults.plumber = false | |
defaults.minify = true | |
} | |
options.debug = options.debug === undefined ? defaults.debug : options.debug | |
options.plumber = options.plumber === undefined ? defaults.plumber : options.plumber | |
options.minify = options.minify === undefined ? defaults.minify : options.minify | |
module.exports = options |
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 gulp = require("gulp") | |
var opts = require("./options") | |
var util = require("gulp-util") | |
var plumber = require("gulp-plumber") | |
var myth = require("gulp-myth") | |
var csso = require("gulp-csso") | |
module.exports = function() { | |
return gulp.src("./src/*.css") | |
.pipe(opts.plumber ? plumber(): util.noop()) | |
.pipe(myth({sourcemap: opts.debug})) | |
.pipe(opts.minify ? csso() : util.noop()) | |
.pipe(gulp.dest("./dist/")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment