Skip to content

Instantly share code, notes, and snippets.

@ScottKaye
Created November 9, 2015 21:38
Show Gist options
  • Save ScottKaye/83f00579754b394f07d2 to your computer and use it in GitHub Desktop.
Save ScottKaye/83f00579754b394f07d2 to your computer and use it in GitHub Desktop.
var gulp = require("gulp");
var buffer = require("vinyl-buffer");
var source = require("vinyl-source-stream");
var sourcemaps = require("gulp-sourcemaps");
var sass = require("gulp-ruby-sass");
var rename = require("gulp-rename");
var autoprefixer = require("gulp-autoprefixer");
var minifycss = require("gulp-minify-css");
var browserify = require("browserify");
gulp.task("sass", function () {
return sass("style/*.scss")
.on("error", sass.logError)
.pipe(autoprefixer({
browsers: ["last 10 versions", "> 5%"],
cascade: false
}))
.pipe(minifycss())
.pipe(rename("style/app.css"))
.pipe(gulp.dest(""));
});
gulp.task("js", function() {
var bundler = browserify("js/src/app-base.js", {
debug: true
})
.transform("babelify", {
presets: ["es2015", "stage-0"]
});
return bundler.bundle()
.on("error", function(err) {
console.error(err);
this.emit("end");
})
.pipe(source("app.js"))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("js/dist/"));
});
gulp.task("default", function(){
gulp.watch("style/*.scss", ["sass"]);
gulp.watch("js/src/*.js", ["js"]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment