Last active
August 12, 2016 06:20
-
-
Save kohki-shikata/b7b9b0bf166fc3f5b82bc896505c0e91 to your computer and use it in GitHub Desktop.
f6 with jade gulpfile.js
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 $ = require('gulp-load-plugins')(); | |
var ejs = require('gulp-ejs'); | |
var jade = require('gulp-jade'); | |
var browserSync = require('browser-sync').create(); | |
var plumber = require('gulp-plumber'); | |
var dir = "../dist/"; | |
var html_preprocessor = "jade"; | |
var sassPaths = [ | |
'bower_components/foundation-sites/scss', | |
'bower_components/motion-ui/src' | |
]; | |
var running_tasks = [ | |
'sass', | |
'browser-sync', | |
html_preprocessor | |
]; | |
gulp.task('browser-sync', function() { | |
browserSync.init({ | |
server: { | |
baseDir: dir | |
} | |
}); | |
}); | |
gulp.task("jade", function() { | |
gulp.src( | |
["jade/**/*.jade",'!' + "jade/**/_*.jade"] | |
) | |
.pipe(plumber()) | |
.pipe(jade({pretty: true})) | |
.pipe(gulp.dest(dir)) | |
.pipe(browserSync.reload({stream:true})); | |
}); | |
gulp.task("ejs", function() { | |
gulp.src( | |
["ejs/**/*.html",'!' + "ejs/**/_*.html"] | |
) | |
.pipe(ejs()) | |
.pipe(gulp.dest(dir)) | |
.pipe(browserSync.reload({stream:true})); | |
}); | |
var copy_js = [ | |
'bower_components/foundation-sites/dist/foundation.min.js', | |
'bower_components/jquery/dist/jquery.min.js', | |
'bower_components/motion-ui/dist/motion-ui.min.js', | |
'bower_components/what-input/what-input.min.js', | |
'js/app.js', | |
]; | |
var copy_css = [ | |
'bower_components/motion-ui/dist/motion-ui.min.css', | |
]; | |
gulp.task('copy', function () { | |
gulp.src(copy_js) | |
.pipe(gulp.dest(dir + 'common/js')); | |
gulp.src(copy_css) | |
.pipe(gulp.dest(dir + 'common/css')); | |
}); | |
gulp.task('sass', function() { | |
return gulp.src('scss/app.scss') | |
.pipe($.sass({ | |
includePaths: sassPaths | |
}) | |
.on('error', $.sass.logError)) | |
.pipe($.autoprefixer({ | |
browsers: ['last 2 versions', 'ie >= 9'] | |
})) | |
.pipe(gulp.dest(dir + 'common/css')) | |
.pipe(browserSync.reload({stream:true})); | |
}); | |
gulp.task('default', running_tasks, function() { | |
gulp.watch(['scss/**/*.scss'], ['sass']); | |
switch(html_preprocessor){ | |
case "jade": | |
gulp.watch(['jade/**/*.jade'], ['jade']); | |
break; | |
case "ejs": | |
gulp.watch(['ejs/**/*.html'], ['ejs']); | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment