Last active
August 29, 2015 14:16
-
-
Save Dafrok/7214fb4e7b2a2d5625b5 to your computer and use it in GitHub Desktop.
sample gulpfile
This file contains hidden or 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 gulpif = require( 'gulp-if') | |
| var jade = require("gulp-jade") | |
| var stylus = require("gulp-stylus") | |
| var autoprefixer = require("gulp-autoprefixer") | |
| var minifyImg = require("gulp-imagemin") | |
| var changed = require("gulp-changed") | |
| var uglify = require("gulp-uglify") | |
| var minifyCss = require("gulp-minify-css") | |
| var browserSync = require('browser-sync') | |
| var sourcemaps = require("gulp-sourcemaps") | |
| var plumber=require("gulp-plumber") | |
| var postcss=require("gulp-postcss") | |
| var util=require("gulp-util") | |
| var cssgrace=require('cssgrace') | |
| var reload=browserSync.reload | |
| var error = function(e){ | |
| util.beep() | |
| util.log(e.toString()) | |
| } | |
| var paths={ | |
| //build | |
| //html:"build/html", | |
| html:"build", | |
| css:"build/css", | |
| js:"build/js", | |
| image:"build/img", | |
| json:"build/data", | |
| //develop | |
| jade:"src/jade/*.jade", | |
| img:"src/img/**", | |
| stylus:"src/stylus/*.styl", | |
| data:"src/data/*.*" | |
| } | |
| gulp.task("browser-sync",function(){ | |
| browserSync({ | |
| server:{ | |
| baseDir:"build" | |
| } | |
| }) | |
| gulp.watch(paths.jade,["html",reload]), | |
| gulp.watch(paths.stylus,["css",reload]), | |
| gulp.watch("src/js/**",["js",reload]) | |
| gulp.watch(paths.img,["img",reload]) | |
| }) | |
| gulp.task("html",function(){ | |
| return gulp.src(paths.jade) | |
| .pipe(plumber({"errorHandler":error})) | |
| .pipe(jade()) | |
| .pipe(gulp.dest(paths.html)) | |
| }) | |
| gulp.task("css", function () { | |
| var processors = [ | |
| cssgrace | |
| ]; | |
| return gulp.src([paths.stylus,"bower_components/typo.css/typo.css"]) | |
| .pipe(plumber({"errorHandler":error})) | |
| .pipe(gulpif("*.styl",stylus())) | |
| .pipe(autoprefixer()) | |
| .pipe(postcss(processors)) | |
| .pipe(minifyCss({compatibility:"ie7"})) | |
| .pipe(gulp.dest(paths.css)) | |
| }) | |
| gulp.task("js", function () { | |
| return gulp.src(['src/js/**/*.js', | |
| '!src/js/**/*.min.js', | |
| 'bower_components/jquery/dist/jquery.min.js', | |
| 'bower_components/json2/json2.js' | |
| ]) | |
| .pipe(plumber({"errorHandler":error})) | |
| .pipe(uglify()) | |
| .pipe(gulp.dest(paths.js)) | |
| }) | |
| gulp.task("img",function(){ | |
| return gulp.src(paths.img) | |
| .pipe(plumber({"errorHandler":error})) | |
| .pipe(minifyImg()) | |
| .pipe(gulp.dest(paths.image)) | |
| }) | |
| gulp.task("data",function(){ | |
| return gulp.src(paths.data) | |
| .pipe(plumber({"errorHandler":error})) | |
| .pipe(gulp.dest(paths.json)) | |
| }) | |
| gulp.task("default", function(){ | |
| gulp.run("html", "css", "js","img","data","browser-sync"); | |
| }) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment