css - gulpfile.js help to add live reload -
wonder if can me solve problem. new gulp , have created gulp file works how want following different guides online.
i trying add css minify , live reload. wonder if can me @ i'm doing not working :(
here's current file. in advance
// include gulp var gulp = require('gulp'); // include our plugins var jshint = require('gulp-jshint'); var sass = require('gulp-sass'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); // lint task gulp.task('lint', function() { return gulp.src('js/*.js') .pipe(jshint()) .pipe(jshint.reporter('default')); }); // compile our sass gulp.task('sass', function() { return gulp.src('styles/*.scss') .pipe(sass()) .pipe(gulp.dest('')); }); // concatenate & minify js gulp.task('scripts', function() { return gulp.src('js/*.js') .pipe(concat('all.js')) .pipe(gulp.dest('dist')) .pipe(rename('all.min.js')) .pipe(uglify()) .pipe(gulp.dest('dist')); }); // watch files changes gulp.task('watch', function() { gulp.watch('js/*.js', ['lint', 'scripts']); gulp.watch('styles/*.scss', ['sass']); }); // default task gulp.task('default', ['lint', 'sass', 'scripts', 'watch']); // include gulp var gulp = require('gulp'); // include our plugins var jshint = require('gulp-jshint'); var sass = require('gulp-sass'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); // lint task gulp.task('lint', function() { return gulp.src('js/*.js') .pipe(jshint()) .pipe(jshint.reporter('default')); }); // compile our sass gulp.task('sass', function() { return gulp.src('styles/*.scss') .pipe(sass()) .pipe(gulp.dest('')); }); // concatenate & minify js gulp.task('scripts', function() { return gulp.src('js/*.js') .pipe(concat('all.js')) .pipe(gulp.dest('dist')) .pipe(rename('all.min.js')) .pipe(uglify()) .pipe(gulp.dest('dist')); }); // watch files changes gulp.task('watch', function() { gulp.watch('js/*.js', ['lint', 'scripts']); gulp.watch('styles/*.scss', ['sass']); }); gulp.task('default', ['lint', 'sass', 'scripts', 'watch']);
your gulpfile looks absolutely fine me. need run watch task , have sass , lint working you. in order start watch task, same directory has gulpfile.js, run command gulp watch
. whenever make changes *.js or *.css files, have live reload working you.
you have add live-reload task. check here: gulp live-reload
Comments
Post a Comment