Created
January 18, 2015 16:24
-
-
Save lperrin/35393393464faccc5215 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
var glou = require('glou'); | |
var gulpIf = require('gulp-if'), | |
gulpInsert = require('gulp-insert'), | |
gulpSourcemaps = require('gulp-sourcemaps'), | |
gulpWrapCommonjs = require('gulp-wrap-commonjs'), | |
gulpNgAnnotate = require('gulp-ng-annotate'), | |
gulpUglify = require('gulp-uglify'), | |
gulpConcat = require('gulp-concat'); | |
var env = { | |
sourcemaps: true, | |
uglify: true | |
}; | |
var commonjs = glou | |
.pipe('commonjs', function () { | |
return gulpWrapCommonjs({ | |
pathModifier: function (path) { | |
path = path.replace(/^.*\/front\//, ''); | |
var nodeModules = /^node_modules\/([^\/]+)\//.exec(path); | |
return nodeModules ? nodeModules[1] : path; | |
} | |
}); | |
}) | |
.src({prepend: true}, 'node_modules/commonjs-require/commonjs-require.js') | |
; | |
var angularjs = glou | |
.src({prepend: true}, [ | |
'node_modules/jquery/dist/jquery.min.js', | |
'node_modules/angular/angular.min.js', | |
'node_modules/angular-animate/angular-animate.min.js', | |
'node_modules/angular-sanitize/angular-sanitize.min.js', | |
'node_modules/angular-messages/angular-messages.min.js', | |
'node_modules/angular-datepicker/dist/index.min.js', | |
'node_modules/contenteditable/angular-contenteditable.js' | |
]) | |
; | |
var buildjs = glou | |
.pipe('sourcemaps init', gulpIf, env.sourcemaps, gulpSourcemaps.init) | |
.pipe(gulpNgAnnotate) | |
.pipe(commonjs) | |
.pipe('uglify', gulpIf, env.uglify, gulpUglify) | |
.pipe('sourcemaps write', gulpIf, env.sourcemaps, gulpSourcemaps.write) | |
.remember() | |
; | |
var frontCommon = glou.src([ | |
'node_modules/underscore/underscore.js', | |
'public/js2/models/**/*(*.js|*.json)', | |
'public/js2/platform/**/*(*.js|*.json)', | |
'public/js2/push/**/*(*.js|*.json)', | |
'public/js2/common/**/*(*.js|*.json)' | |
]); | |
var app = glou | |
.src([ | |
'node_modules/twitter-text/twitter-text.js', | |
'node_modules/moment/moment.js', | |
'node_modules/moment-timezone/moment-timezone.js', | |
'node_modules/chart/Chart.js', | |
'node_modules/phone/lib/index.js', | |
'public/js2/app/**/*(*.js|*.json)', | |
'public/js2/composer/**/*(*.js|*.json)', | |
'public/js2/cards/**/*(*.js|*.json)', | |
'public/js2/settings/**/*(*.js|*.json)', | |
'public/js2/welcome/**/*(*.js|*.json)', | |
'public/js2/app.js' | |
]) | |
.pipe(frontCommon) | |
.pipe(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/payment/lib/jquery.payment.js', | |
'node_modules/ui-router/release/angular-ui-router.min.js', | |
]) | |
.pipe(angularjs) | |
.pipe('concat', gulpConcat, 'app.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/app.js");') | |
.dest('public/js/build') | |
; | |
var composer = glou | |
.src([ | |
'public/js2/composer/**/*(*.js|*.json)', | |
'public/js2/composer.js' | |
]) | |
.pipe(frontCommon) | |
.pipe(buildjs) | |
.pipe(angularjs) | |
.pipe('concat', gulpConcat, 'composer.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/composer.js");') | |
.dest('public/js/build') | |
; | |
var settings = glou | |
.src([ | |
'public/js2/settings/**/*(*.js|*.json)', | |
'public/js2/settings.js' | |
]) | |
.pipe(frontCommon) | |
.pipe(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/payment/lib/jquery.payment.js' | |
]) | |
.pipe(angularjs) | |
.pipe('concat', gulpConcat, 'settings.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/settings.js");') | |
.dest('public/js/build') | |
; | |
var cards = glou | |
.src([ | |
'public/js2/cards/**/*(*.js|*.json)', | |
'public/js2/cards.js' | |
]) | |
.pipe(frontCommon) | |
.pipe(buildjs) | |
.pipe(angularjs) | |
.pipe('concat', gulpConcat, 'cards.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/cards.js");') | |
.dest('public/js/build') | |
; | |
glou.task('js', glou.parallel([app, composer, settings, cards])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment