Skip to content

Instantly share code, notes, and snippets.

@omniphx
Created December 3, 2015 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omniphx/03f1650efc04c5a47196 to your computer and use it in GitHub Desktop.
Save omniphx/03f1650efc04c5a47196 to your computer and use it in GitHub Desktop.
Gulp configuration for handling static resources
var gulp = require('gulp'),
shell = require('gulp-shell'),
zip = require('gulp-zip'),
minifyCSS = require('gulp-minify-css'),
less = require('gulp-less'),
debug = require('gulp-debug'),
gutil = require('gulp-util');
gulp.task('update', shell.task(
'bower update'
));
gulp.task('less', function () {
gulp.src('./less/bootstrap.less')
.pipe(less({
paths: ['./less']
}))
.pipe(gulp.dest('./resource-bundles/bootstrap.resource'));
});
gulp.task('compress', function(){
gulp.src('./resource-bundles/bootstrap.resource/bootstrap.css')
.pipe(minifyCSS())
.pipe(gulp.dest('./resource-bundles/bootstrap.resource'));
});
gulp.task('bootstrap', function(){
gulp.src('./bower_components/bootstrap-sf1/dist/**')
.pipe(gulp.dest('./resource-bundles/bootstrap.resource/'));
});
gulp.task('angular', function(){
gulp.src('./bower_components/angular/**')
.pipe(gulp.dest('./resource-bundles/angular.resource/'));
});
gulp.task('angular-maps', function(){
gulp.src('./bower_components/angular-google-maps/dist/**')
.pipe(gulp.dest('./resource-bundles/angularGoogleMaps.resource/'));
});
gulp.task('lodash', function(){
gulp.src('./bower_components/lodash/dist/**')
.pipe(gulp.dest('./resource-bundles/lodash.resource/'));
});
gulp.task('angular-route', function(){
gulp.src('./bower_components/angular-route/**')
.pipe(gulp.dest('./resource-bundles/angularRoute.resource/'));
});
gulp.task('zip-scripts', function(){
return gulp.src('./resource-bundles/scripts.resource/*')
.pipe(zip('scripts.resource'))
.pipe(gulp.dest('./src/staticresources'));
});
gulp.task('zip-styles', function(){
return gulp.src('./resource-bundles/styles.resource/*')
.pipe(zip('styles.resource'))
.pipe(gulp.dest('./src/staticresources'));
});
gulp.task('compile-scripts', function(){
return gulp.src('./src/staticresources/scripts.resource')
.pipe(shell(['mm compile <<< \'{"project_name": "DEV1", "files": ["/Users/mjmitchener/Salesforce/workspace/DEV1/src/staticresources/scripts.resource"], "workspace": "/Users/mjmitchener/Salesforce/workspace"}\''], {
quiet:true
}));
});
gulp.task('compile-styles', shell.task(
'mm compile <<< \'{"project_name": "DEV1", "files": ["/Users/mjmitchener/Salesforce/workspace/DEV1/src/staticresources/styles.resource"], "workspace": "/Users/mjmitchener/Salesforce/workspace"}\'',
{ quiet:true }
));
gulp.task('bower-watch', function(){
gulp.watch('./bower_components/bootstrap-sf1/dist/**', ['bootstrap']);
gulp.watch('./bower_components/angular/**', ['angular']);
gulp.watch('./bower_components/angular-google-maps/dist/**', ['angular-maps']);
gulp.watch('./bower_components/lodash/dist/**', ['lodash']);
gulp.watch('./bower_components/angular-route/**', ['angular-route']);
});
gulp.task('resources', function(){
gulp.watch('./resource-bundles/scripts.resource/**', ['zip-scripts']);
gulp.watch('./src/staticresources/scripts.resource', ['compile-scripts']);
gulp.watch('./resource-bundles/styles.resource/**', ['zip-styles']);
gulp.watch('./src/staticresources/styles.resource', ['compile-styles']);
});
gulp.task('refresh', ['bootstrap','angular','lodash']);
gulp.task('default', ['resources']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment