Last active
August 29, 2015 14:05
-
-
Save uditveerwani/4e3e2bd591806854671e to your computer and use it in GitHub Desktop.
Roots task for Gulp
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! | |
var less = require('gulp-less'); // Less | |
var prefix = require('gulp-autoprefixer'); // Autoprefixr | |
var minifycss = require('gulp-minify-css'); // Minify CSS | |
var concat = require('gulp-concat'); // Concat files | |
var uglify = require('gulp-uglify'); // Uglify javascript | |
var rename = require('gulp-rename'); // Rename files | |
var util = require('gulp-util'); // Logging | |
var livereload = require('gulp-livereload'); // LiveReload | |
var jshint = require("gulp-jshint"); // jshint | |
/*********************************** | |
* Compile all CSS for the site | |
**********************************/ | |
gulp.task('less', function (){ | |
gulp.src([ | |
'assets/less/main.less']) // Gets the apps scss | |
.pipe(less({style: 'compressed', errLogToConsole: true})) // Compile sass | |
.pipe(concat('main.css')) // Concat all css | |
.pipe(prefix("last 1 version", "> 1%", "ie 8", "ie 7")) // Auto Prefix | |
.pipe(rename({suffix: '.min'})) // Rename it | |
.pipe(minifycss()) // Minify the CSS | |
.pipe(gulp.dest('assets/css/')) // Set the destination to assets/css | |
.pipe(livereload()); // Reloads server | |
util.log(util.colors.yellow('Less compiled & minified')); // Output to terminal | |
}); | |
/*************************************** | |
* Get all the JS, concat and uglify | |
**************************************/ | |
gulp.task('javascripts', function(){ | |
gulp.src([ | |
// Gets Foundation JS change to only include the scripts you'll need | |
'assets/vendor/bootstrap/js/transition.js', | |
'assets/vendor/bootstrap/js/alert.js', | |
'assets/vendor/bootstrap/js/button.js', | |
'assets/vendor/bootstrap/js/carousel.js', | |
'assets/vendor/bootstrap/js/collapse.js', | |
'assets/vendor/bootstrap/js/dropdown.js', | |
'assets/vendor/bootstrap/js/modal.js', | |
'assets/vendor/bootstrap/js/tooltip.js', | |
'assets/vendor/bootstrap/js/popover.js', | |
'assets/vendor/bootstrap/js/scrollspy.js', | |
'assets/vendor/bootstrap/js/tab.js', | |
'assets/vendor/bootstrap/js/affix.js', | |
'assets/js/plugins/*.js', | |
'assets/js/_*.js']) // Gets all the user JS _*.js from assets/js | |
.pipe(concat('scripts.js')) // Concat all the scripts | |
.pipe(rename({suffix: '.min'})) // Rename it | |
.pipe(uglify()) // Uglify(minify) | |
.pipe(gulp.dest('assets/js/')) // Set destination to assets/js | |
.pipe(livereload()); // Reloads server | |
util.log(util.colors.yellow('Javascripts compiled and minified')); | |
}); | |
/**************** | |
* JS hint | |
***************/ | |
gulp.task('jshint', function() { | |
gulp.src('assets/js/_*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish')); | |
}); | |
/*********************************** | |
* Default Gulp Task | |
**********************************/ | |
gulp.task('watch', function(){ | |
var server = livereload(); | |
gulp.watch('**/*.php').on('change', function(file) { | |
server.changed(file.path); | |
util.log(util.colors.yellow('PHP file changed' + ' (' + file.path + ')')); | |
}); | |
gulp.watch("assets/less/**/*.less", ['less']); // Watch and run sass on changes | |
gulp.watch("assets/js/_*.js", ['jshint', 'javascripts']); // Watch and run javascripts on changes | |
}); | |
gulp.task('default', ['less', 'jshint', 'javascripts', 'watch']); |
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
{ | |
"name": "roots", | |
"version": "7.0.0", | |
"author": "Ben Word <ben@benword.com>", | |
"homepage": "http://roots.io", | |
"repository": { | |
"type": "git", | |
"url": "git://github.com/roots/roots.git" | |
}, | |
"bugs": { | |
"url": "https://github.com/roots/roots/issues" | |
}, | |
"licenses": [ | |
{ | |
"type": "MIT", | |
"url": "http://opensource.org/licenses/MIT" | |
} | |
], | |
"scripts": { | |
"postinstall": "node node_modules/bower/bin/bower install && grunt dev" | |
}, | |
"engines": { | |
"node": ">= 0.10.0" | |
}, | |
"devDependencies": { | |
"bower": ">=1.3.9", | |
"gulp": "*", | |
"gulp-autoprefixer": "*", | |
"gulp-concat": "*", | |
"gulp-imagemin": "*", | |
"gulp-jshint": "*", | |
"gulp-livereload": "*", | |
"gulp-minify-css": "*", | |
"gulp-rename": "*", | |
"gulp-less": "*", | |
"gulp-uglify": "*", | |
"gulp-util": "*", | |
"jshint-stylish": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment