Created
April 7, 2015 11:49
-
-
Save lishiyo/3193eb9c1e9684948a6d to your computer and use it in GitHub Desktop.
Gulpfile-Plugins
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'); | |
var plugins = require("gulp-load-plugins")({ | |
pattern: ['gulp-*', 'gulp.*', 'main-bower-files'], | |
replaceString: /\bgulp[\-.]/ | |
}); | |
var dest = "./public/"; | |
var src = './src/'; | |
var clientJS = src + 'js/*.js'; | |
var clientSCSS = src + 'css/*.scss'; | |
// entrance point that loads all requires | |
var module = './src/js/index.js'; | |
// BUILD BOWER | |
// concat into src/js/vendor and minify into public/js | |
gulp.task('bowerify', function() { | |
return gulp.src(plugins.mainBowerFiles()) | |
.pipe(plugins.filter('*.js')) | |
.pipe(plugins.concat('vendor.js')) | |
.pipe(gulp.dest(src + 'js/vendor')) | |
.pipe(plugins.uglify()) | |
.pipe(plugins.rename('vendor.min.js')) | |
.pipe(gulp.dest(dest + 'js')); | |
}); | |
// BUILD NPM | |
gulp.task('lint-client', function() { | |
return gulp.src(clientJS) | |
.pipe(plugins.jshint()) | |
.pipe(plugins.jshint.reporter('default')); | |
}); | |
gulp.task('browserify-client', ['lint-client'], function() { | |
return gulp.src(module) | |
.pipe(plugins.browserify({ | |
insertGlobals: true | |
})) | |
.pipe(plugins.rename('bundle.js')) | |
.pipe(gulp.dest('public/js')); | |
}); | |
gulp.task('styles', function() { | |
return gulp.src('src/css/*.scss') | |
.pipe(plugins.concat('bundle.scss')) | |
.pipe(plugins.sass()) | |
.pipe(plugins.autoprefixer({ cascade: true })) | |
.pipe(plugins.rename('bundle.css')) | |
.pipe(gulp.dest(dest + 'css')); | |
}); | |
gulp.task('watch', function(){ | |
gulp.watch(clientJS, ['browserify-client']); | |
gulp.watch(clientSCSS, ['styles']); | |
}); | |
gulp.task('default', ['bowerify', 'browserify-client', 'styles', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment