Skip to content

Instantly share code, notes, and snippets.

@patrickng patrickng/gulpfile.js
Last active Aug 29, 2015

Embed
What would you like to do?
Gulp SASS + BrowserSync + JS
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var reload = browserSync.reload;
var onError = function (err) {
gutil.beep();
gutil.log(gutil.colors.red(err.message));
this.emit('end');
};
// --- Basic Tasks ---
gulp.task('sass', function() {
return gulp.src('scss/style.scss')
.pipe(
sass({
includePaths: ['scss/bootstrap', 'scss/vendor'],
errLogToConsole: true
}))
.pipe(gulp.dest('htdocs/css'));
.pipe(autoprefixer({
browsers: ['last 2 versions', 'ie 9'],
cascade: false
}))
.pipe(reload({stream: true}));
});
gulp.task('js', function() {
return gulp.src(['htdocs/js/**/*.js'])
.pipe(concat('build.min.js'))
.pipe(uglify())
.pipe(gulp.dest('htdocs/js'));
});
gulp.task('serve', function() {
browserSync({
proxy: "localhost.dev"
});
gulp.watch('scss/**/*.scss', ['sass']);
gulp.watch(['htdocs/index.php', 'application/views/**/*.php', 'htdocs/js/**/*.js']).on('change', reload);
});
// Default Task
gulp.task('default', ['sass', 'js', 'serve']);
{
"name": "gulp",
"version": "0.1.0",
"description": "Gulp Recipe - Sass, BrowserSync, JS",
"author": "Patrick Ng",
"devDependencies": {
"browser-sync": "^2.7.13",
"gulp": "~3.9.0",
"gulp-autoprefixer": "^2.3.1",
"gulp-concat": "^2.6.0",
"gulp-plumber": "^1.0.1",
"gulp-sass": "~2.0.3",
"gulp-uglify": "^1.2.0",
"gulp-util": "~3.0.6",
"gulp-sourcemaps": "~1.5.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.