Created
May 30, 2014 03:37
-
-
Save clouddueling/305579a54dbe221c0728 to your computer and use it in GitHub Desktop.
I have a few gulpfiles. One manages my theme in multiple apps and the other manages the app's unique stuff.
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
// Keeps my theme synced in multiple apps | |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var compass = require('gulp-compass'); | |
var clean = require('gulp-clean'); | |
/* | |
|-------------------------------------------------------------------------- | |
| Config | |
|-------------------------------------------------------------------------- | |
*/ | |
// Global App CSS | |
var targetCSSDir = '.tmp/styles'; | |
// Standard App CSS Dir | |
var appCSSDir = '/public/dist/styles'; | |
// All app dirs | |
var appDirs = ['owner', 'client', 'middle']; | |
// iFlat SASS | |
var iflatSassDir = 'assets/iflat/styles'; | |
// REEN SASS | |
var reenSassDir = 'assets/reen/styles'; | |
/* | |
|-------------------------------------------------------------------------- | |
| Release Tasks | |
|-------------------------------------------------------------------------- | |
| | |
| Run before each commit and is then pushed to staging and production. | |
| | |
*/ | |
// What tasks does running gulp trigger? | |
gulp.task('default', ['css', 'watch']); | |
gulp.task('release-css', ['css-iflat', 'release-iflat', 'css-reen', 'release-reen']); | |
/* | |
|-------------------------------------------------------------------------- | |
| Watch Tasks | |
|-------------------------------------------------------------------------- | |
*/ | |
// Keep an eye on Sass, Coffee, and PHP files for changes... | |
gulp.task('watch-iflat', function () { | |
gulp.watch(iflatSassDir + '/**/*.scss', ['css-iflat', 'release-iflat']); | |
}); | |
gulp.task('watch-reen', function () { | |
gulp.watch(reenSassDir + '/**/*.scss', ['css-reen', 'release-reen']); | |
}); | |
/* | |
|-------------------------------------------------------------------------- | |
| Small Tasks | |
|-------------------------------------------------------------------------- | |
| | |
| Small pieces release tasks so you can be specific in your watch tasks. | |
| | |
*/ | |
// Compile iFlat SCSS | |
gulp.task('css-iflat', function () { | |
return gulp.src(iflatSassDir + '/iflat.scss') | |
.pipe(compass({ | |
compress: true, | |
css: targetCSSDir, | |
sass: iflatSassDir | |
})).on('error', gutil.log) | |
.pipe(gulp.dest(targetCSSDir)); | |
}); | |
// Copy iFlat styles to each app | |
gulp.task('release-iflat', function () { | |
for (var dir in appDirs) { | |
gutil.log("Copying '" + targetCSSDir + "/iflat.css' to '" + appDirs[dir] + appCSSDir + "/iflat.css'"); | |
gulp.src(targetCSSDir + '/iflat.css') | |
.pipe(clean()) | |
.pipe(gulp.dest(appDirs[dir] + appCSSDir)); | |
} | |
}); | |
// Compile REEN SCSS | |
gulp.task('css-reen', function () { | |
return gulp.src(reenSassDir + '/reen.scss') | |
.pipe(compass({ | |
compress: true, | |
css: targetCSSDir, | |
sass: reenSassDir | |
})).on('error', gutil.log) | |
.pipe(gulp.dest(targetCSSDir)); | |
}); | |
// Copy REEN styles to each app | |
gulp.task('release-reen', function () { | |
for (var dir in appDirs) { | |
gutil.log("Copying '" + targetCSSDir + "/reen.css' to '" + appDirs[dir] + appCSSDir + "/reen.css'"); | |
gulp.src(targetCSSDir + '/reen.css') | |
.pipe(clean()) | |
.pipe(gulp.dest(appDirs[dir] + appCSSDir)); | |
} | |
}); |
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
// From one of the apps that has it's theme managed by the other gulpfile.js | |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var clean = require('gulp-clean'); | |
var coffee = require('gulp-coffee'); | |
var concat = require('gulp-concat'); | |
/* | |
|-------------------------------------------------------------------------- | |
| Config | |
|-------------------------------------------------------------------------- | |
*/ | |
// Coffee and SCSS files | |
var assetsDir = 'app/assets'; | |
// Temporary dir before concating | |
var tempDir = '.tmp'; | |
// HTML files and concatenated and minified JS | |
var distDir = 'public/dist'; | |
// bower_components | |
var bowerDir = 'public/bower_components'; | |
/* | |
|-------------------------------------------------------------------------- | |
| Release Tasks | |
|-------------------------------------------------------------------------- | |
| | |
| Run before each commit and is then pushed to staging and production. | |
| | |
*/ | |
// TODO Add phpunit | |
// TODO Add karma + protractor | |
// TODO Create a 'release' task that runs everything including tests | |
gulp.task('release-owner', [ | |
'release-owner-clean', | |
'release-owner-copy-views', | |
'release-owner-coffee', | |
'release-owner-concat' | |
]); | |
gulp.task('release-owner-vendor', [ | |
'release-owner-vendor-clean', | |
'release-owner-vendor-concat' | |
]); | |
/* | |
|-------------------------------------------------------------------------- | |
| Watch Tasks | |
|-------------------------------------------------------------------------- | |
*/ | |
gulp.task('watch-release-owner', function() { | |
gulp.watch(assetsDir + '/**/*.html', ['release-owner-copy-views']); | |
gulp.watch(assetsDir + '/**/*.coffee', ['release-owner-clean', 'release-owner-coffee', 'release-owner-concat']); | |
}); | |
/* | |
|-------------------------------------------------------------------------- | |
| Small Tasks | |
|-------------------------------------------------------------------------- | |
| | |
| Small pieces release tasks so you can be specific in your watch tasks. | |
| | |
*/ | |
gulp.task('release-owner-clean', function() { | |
// Delete old app files | |
return gulp.src([ | |
assetsDir + '/owner/**/[!ownerVendor]*.js', | |
tempDir + '/owner/**/*.js' | |
]) | |
.pipe(clean()); | |
}); | |
gulp.task('release-owner-copy-views', function() { | |
// Copy views to dist | |
return gulp.src(assetsDir + '/owner/**/*.html') | |
.pipe(gulp.dest(distDir + '/owner')); | |
}); | |
// Compile coffee to js | |
gulp.task('release-owner-coffee', function() { | |
return gulp.src(assetsDir + '/owner/**/*.coffee') | |
.pipe(coffee({bare: true}).on('error', gutil.log)) | |
.pipe(gulp.dest(tempDir + '/owner')); | |
}); | |
// Concat js and copy to dist | |
gulp.task('release-owner-concat', function() { | |
return gulp.src(tempDir + '/owner/**/*.js') | |
.pipe(concat('owner.js')) | |
.pipe(gulp.dest(distDir + '/owner')); | |
}); | |
// Delete old vendor file | |
gulp.task('release-owner-vendor-clean', function() { | |
return gulp.src('public/dist/owner/ownerVendor.js') | |
.pipe(clean()); | |
}); | |
// Concat owner vendor files | |
// TODO make this array smaller or located in package.json | |
gulp.task('release-owner-vendor-concat', function() { | |
gulp.src([ | |
bowerDir + '/lodash/dist/lodash.min.js', | |
bowerDir + '/momentjs/min/moment.min.js', | |
bowerDir + '/jquery/dist/jquery.min.js', | |
bowerDir + '/bootstrap/dist/js/bootstrap.min.js', | |
bowerDir + '/angular/angular.min.js', | |
bowerDir + '/angular-animate/angular-animate.min.js', | |
bowerDir + '/angular-bootstrap/ui-bootstrap-tpls.min.js', | |
bowerDir + '/angular-ui-router/release/angular-ui-router.min.js', | |
bowerDir + '/angular-loading-bar/build/loading-bar.min.js', | |
bowerDir + '/angular-ui-calendar/src/calendar.js', | |
bowerDir + '/jquery-spinner/dist/jquery.spinner.min.js', | |
bowerDir + '/seiyria-bootstrap-slider/dist/bootstrap-slider.min.js', | |
bowerDir + '/jquery-steps/build/jquery.steps.min.js', | |
bowerDir + '/toastr/toastr.min.js', | |
bowerDir + '/bootstrap-file-input/bootstrap.file-input.js', | |
bowerDir + '/jquery.slimscroll/jquery.slimscroll.min.js', | |
bowerDir + '/holderjs/holder.js', | |
bowerDir + '/raphael/raphael-min.js', | |
bowerDir + '/morris.js/morris.js', | |
bowerDir + '/scripts/vendors/responsive-tables.js', | |
bowerDir + '/scripts/vendors/jquery.sparkline.min.js', | |
bowerDir + '/flot/jquery.flot.js', | |
bowerDir + '/flot/jquery.flot.resize.js', | |
bowerDir + '/flot/jquery.flot.pie.js', | |
bowerDir + '/flot/jquery.flot.stack.js', | |
bowerDir + '/flot/jquery.flot.time.js', | |
bowerDir + '/gauge.js/dist/gauge.min.js', | |
bowerDir + '/jquery.easy-pie-chart/dist/angular.easypiechart.min.js', | |
bowerDir + '/angular-wizard/dist/angular-wizard.min.js', | |
bowerDir + '/fullcalendar/fullcalendar.min.js', | |
bowerDir + '/fullcalendar/gcal.js', | |
bowerDir + '/angularjs-imageupload-directive/public/javascripts/imageupload.js', | |
'../../clouddueling/public/modules/time/time.js' | |
]) | |
.pipe(concat('ownerVendor.js')) | |
.pipe(gulp.dest('./public/dist/owner')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment