Last active
October 2, 2015 21:42
-
-
Save byronferguson/2459006d99bdd95eb342 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"prebuild": [ | |
"angular", | |
"angular-ui-router", | |
"angular-utf8-base64", | |
"ng-fastclick" | |
], | |
"paths": { | |
"angular" : "bower_components/angular/angular.js", | |
"angular-ui-router" : "bower_components/angular-ui-router/release/angular-ui-router.js", | |
"angular-utf8-base64" : "bower_components/angular-utf8-base64/angular-utf8-base64.js", | |
"ng-fastclick" : "bower_components/ng-fastclick/dist/index.js" | |
} | |
} |
This file contains hidden or 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 es = require('event-stream'); | |
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var connect = require('gulp-connect'); | |
var templateCache = require('gulp-angular-templatecache'); | |
var ngAnnotate = require('gulp-ng-annotate'); | |
var uglify = require('gulp-uglify'); | |
var scripts = require('./app.scripts.json'); | |
var source = { | |
js: { | |
main: 'app/main.js', | |
src: [ | |
// main module | |
'app/app.js', | |
// module files | |
'app/**/module.js', | |
// other js files [controllers, services, etc.] | |
'app/**/!(module)*.js', | |
], | |
tpl: 'app/**/*.tpl.html' | |
} | |
}; | |
var destinations = { | |
js: 'build' | |
}; | |
gulp.task('build', function(){ | |
return es.merge(gulp.src(source.js.src) , getTemplateStream()) | |
.pipe(ngAnnotate()) | |
// .pipe(uglify()) | |
.pipe(concat('app.js')) | |
.pipe(gulp.dest(destinations.js)); | |
}); | |
gulp.task('vendor', function(){ | |
var paths = []; | |
scripts.prebuild.forEach(function(script){ | |
paths.push(scripts.paths[script]); | |
}); | |
gulp.src(paths) | |
.pipe(concat('vendor.js')) | |
//.on('error', swallowError) | |
//.pipe(uglify()) | |
.pipe(gulp.dest(destinations.js)) | |
}); | |
gulp.task('watch', function(){ | |
gulp.watch(source.js.src, ['build']); | |
gulp.watch(source.js.tpl, ['build']); | |
}); | |
gulp.task('connect', function() { | |
connect.server({ | |
port: 8080 | |
}); | |
}); | |
//gulp.task('default', ['vendor', 'build', 'watch', 'connect']); | |
gulp.task('default', ['vendor', 'build', 'watch']); | |
var swallowError = function(error){ | |
console.log(error.toString()); | |
this.emit('end') | |
}; | |
var getTemplateStream = function () { | |
return gulp.src(source.js.tpl) | |
.pipe(templateCache({ | |
root: 'app/', | |
module: 'app' | |
})) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment