Last active
August 29, 2015 14:01
-
-
Save naotone/e377101fa342027db408 to your computer and use it in GitHub Desktop.
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
//npm install --save-dev gulp gulp-watch gulp-livereload gulp-header gulp-concat gulp-coffee gulp-compass gulp-minify-css gulp-notify gulp-uglify gulp-order gulp-ruby-sass | |
var gulp = require('gulp'), | |
watch = require('gulp-watch'), | |
livereload = require('gulp-livereload'), | |
header = require('gulp-header'), | |
concat = require('gulp-concat'), | |
coffee = require('gulp-coffee'), | |
compass = require('gulp-compass'), | |
minifyCSS = require('gulp-minify-css'), | |
notify = require("gulp-notify"), | |
uglify = require("gulp-uglify"), | |
order = require("gulp-order"), | |
sass = require('gulp-ruby-sass'); | |
var paths = { | |
coffee: ['dev/coffee/*.coffee'], | |
js: ['js/vendor/*.js','js/app/*.js'], | |
sass: 'dev/sass/*.sass', | |
css: ['css/*.css'], | |
images: 'client/img/**/*', | |
html: ['**/*.html', '**/*.php'] | |
}; | |
gulp.task('compass', function () { | |
gulp.src(paths.sass) | |
.pipe(compass({ | |
//config_file: './config.rb', | |
css: 'css', | |
sass: 'dev/sass', | |
image: 'images', | |
javascript: 'js', | |
comments: false, | |
style: 'nested' //nested, compressed | |
// logging: false | |
})) | |
.pipe(gulp.dest('css')) | |
.pipe(livereload()) | |
.pipe(notify("gulp: compass finished.")); | |
}); | |
gulp.task('coffee', function () { | |
gulp.src(paths.coffee) | |
.pipe(coffee()) | |
.pipe(gulp.dest('js/app')); | |
// .pipe(livereload()) | |
// .pipe(notify("gulp: coffee finished.")); | |
}); | |
gulp.task('js', function(){ | |
gulp.src(paths.js) | |
.pipe(concat('all.js')) | |
.pipe(order([ | |
"vendor/*.js", | |
"app/*.js" | |
])) | |
.pipe(gulp.dest('js')); | |
}); | |
gulp.task('html', function () { | |
var reload_script; | |
reload_script = "<script>document.write('<script src=\"http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1\"></' + 'script>')</script>"; | |
gulp.src('./*.html') | |
.pipe(header(reload_script, {})) | |
.pipe(gulp.dest('./')); | |
}); | |
///////////////////////////////////////////////////////////////// | |
gulp.task('default', function () { | |
gulp.run('compass', 'coffee','js'); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(paths.sass, ['compass']); | |
gulp.watch(paths.coffee, ['coffee']); | |
gulp.watch(paths.js, ['js']); | |
// gulp.watch(paths.html, ['html']); | |
var server = livereload(); | |
gulp.watch(['css/*.css','js/*.js','**/*.html','**/*.php']).on('change', function(file) { | |
server.changed(file.path); | |
}); | |
}); | |
gulp.task('release', function () { | |
gulp.src('css/style.css') | |
.pipe(minifyCSS()) | |
.pipe(gulp.dest('release/css')); | |
gulp.src('js/all.js') | |
.pipe(uglify()) | |
.pipe(gulp.dest('release/js')); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment