Permalink
Browse files

Gulp dependencies and tasks

  • Loading branch information...
bueltge committed Apr 29, 2014
1 parent 54c1c2c commit 8400f097d4ddcddc93d6c373ad1f202fe5772e09
Showing with 101 additions and 1 deletion.
  1. +88 −0 gulpfile.js
  2. +13 −1 package.json
View
@@ -0,0 +1,88 @@
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-clean gulp-notify gulp-rename gulp-livereload gulp-cache --save-dev
*
* much helpful
* @see http://markgoodyear.com/2014/01/getting-started-with-gulp/
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload');
// Styles
gulp.task('styles', function() {
return gulp.src('src/styles/main.scss')
.pipe(sass({ style: 'expanded', }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/styles'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('dist/styles'))
.pipe(notify({ message: 'Styles task complete' }));
});
// Scripts
gulp.task('scripts', function() {
return gulp.src('src/scripts/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/scripts'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/scripts'))
.pipe(notify({ message: 'Scripts task complete' }));
});
// Images
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('dist/images'))
.pipe(notify({ message: 'Images task complete' }));
});
// Clean
gulp.task('clean', function() {
return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {read: false})
.pipe(clean());
});
// Default task
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'images');
});
// Watch
gulp.task('watch', function() {
// Watch .scss files
gulp.watch('src/styles/**/*.scss', ['styles']);
// Watch .js files
gulp.watch('src/scripts/**/*.js', ['scripts']);
// Watch image files
gulp.watch('src/images/**/*', ['images']);
// Create LiveReload server
var server = livereload();
// Watch any files in dist/, reload on change
gulp.watch(['dist/**']).on('change', function(file) {
server.changed(file.path);
});
});
View
@@ -8,6 +8,18 @@
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.4.3",
"matchdep": "~0.1.2",
"grunt-contrib-cssmin": "~0.6.1"
"grunt-contrib-cssmin": "~0.6.1",
"gulp-rename": "~1.2.0",
"gulp-concat": "~2.2.0",
"gulp-clean": "~0.2.4",
"gulp-minify-css": "~0.3.2",
"gulp-ruby-sass": "~0.4.3",
"gulp-livereload": "~1.3.1",
"gulp-autoprefixer": "0.0.7",
"gulp-uglify": "~0.2.1",
"gulp-notify": "~1.2.5",
"gulp-jshint": "~1.5.5",
"gulp-cache": "~0.1.3",
"gulp-imagemin": "~0.5.0"
}
}

0 comments on commit 8400f09

Please sign in to comment.