Created
February 5, 2014 05:38
-
-
Save gweatherson/8817966 to your computer and use it in GitHub Desktop.
why isn't this compiling upon file changes for css & 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
// 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'), | |
lr = require('tiny-lr'), | |
server = lr(); | |
// Styles | |
gulp.task('styles', function() { | |
return gulp.src('css/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(livereload(server)) | |
.pipe(gulp.dest('dist/styles')) | |
.pipe(notify({ message: 'Styles task complete' })); | |
}); | |
// Scripts | |
gulp.task('scripts', function() { | |
return gulp.src('js/**/*.js') | |
// .pipe(jshint('.jshintrc')) | |
// .pipe(jshint.reporter('default')) | |
.pipe(concat('main.js')) | |
.pipe(gulp.dest('dist/scripts')) | |
.pipe(rename({ suffix: '.min' })) | |
.pipe(uglify()) | |
.pipe(livereload(server)) | |
.pipe(gulp.dest('dist/scripts')) | |
.pipe(notify({ message: 'Scripts task complete' })); | |
}); | |
// Clean | |
gulp.task('clean', function() { | |
return gulp.src(['dist/styles', 'dist/scripts'], {read: false}) | |
.pipe(clean()); | |
}); | |
// Default task | |
gulp.task('default', ['clean'], function() { | |
gulp.start('styles', 'scripts'); | |
}); | |
// Watch | |
gulp.task('watch', function() { | |
// Listen on port 35729 | |
server.listen(35729, function (err) { | |
if (err) { | |
return console.log(err) | |
}; | |
// Watch .scss files | |
gulp.watch('css', ['styles']); | |
// Watch .js files | |
gulp.watch('js', ['scripts']); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment