Created
January 19, 2015 22:35
-
-
Save lperrin/6253590db25a5c303b80 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: false, | |
uglify: true | |
}; | |
var buildjs = glou | |
.pipe('sourcemaps init', env.sourcemaps ? gulpSourcemaps.init : glou.plugins.noop) | |
.pipe(gulpNgAnnotate) | |
.pipe('commonjs', function () { | |
return gulpWrapCommonjs({ | |
pathModifier: function (path) { | |
path = path.replace(/^.*\/front\//, ''); | |
var nodeModules = /^node_modules\/([^\/]+)\//.exec(path); | |
return nodeModules ? nodeModules[1] : path; | |
} | |
}); | |
}) | |
.pipe('uglify', env.uglify ? gulpUglify : glou.plugins.noop) | |
.pipe('sourcemaps write', env.sourcemaps ? gulpSourcemaps.write : glou.plugins.noop) | |
.remember() | |
; | |
var frontCommon = [ | |
'node_modules/underscore/underscore-min.js', | |
'public/js2/models/**/*(*.js|*.json)', | |
'public/js2/platform/**/*(*.js|*.json)', | |
'public/js2/push/**/*(*.js|*.json)', | |
'public/js2/common/**/*(*.js|*.json)' | |
]; | |
var angularjs = [ | |
'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 app = glou | |
.src(frontCommon) | |
.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(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/commonjs-require/commonjs-require.js', | |
'node_modules/payment/lib/jquery.payment.js', | |
'node_modules/ui-router/release/angular-ui-router.min.js' | |
]) | |
.src({prepend: true}, angularjs) | |
.pipe('concat', gulpConcat, 'app.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/app.js");') | |
.dest('public/js/build') | |
; | |
var composer = glou | |
.src(frontCommon) | |
.src([ | |
'node_modules/twitter-text/twitter-text.js', | |
'node_modules/moment/moment.js', | |
'node_modules/moment-timezone/moment-timezone.js', | |
'node_modules/phone/lib/index.js', | |
'public/js2/composer/**/*(*.js|*.json)', | |
'public/js2/composer.js' | |
]) | |
.pipe(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/commonjs-require/commonjs-require.js' | |
]) | |
.src({prepend: true}, angularjs) | |
.pipe('concat', gulpConcat, 'composer.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/composer.js");') | |
.dest('public/js/build') | |
; | |
var settings = glou | |
.src(frontCommon) | |
.src([ | |
'public/js2/settings/**/*(*.js|*.json)', | |
'public/js2/settings.js' | |
]) | |
.pipe(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/commonjs-require/commonjs-require.js', | |
'node_modules/payment/lib/jquery.payment.js' | |
]) | |
.src({prepend: true}, angularjs) | |
.pipe('concat', gulpConcat, 'settings.min.js') | |
.pipe(gulpInsert.append, 'require("public/js2/settings.js");') | |
.dest('public/js/build') | |
; | |
var cards = glou | |
.src(frontCommon) | |
.src([ | |
'public/js2/cards/**/*(*.js|*.json)', | |
'public/js2/cards.js' | |
]) | |
.pipe(buildjs) | |
.src({prepend: true}, [ | |
'node_modules/commonjs-require/commonjs-require.js' | |
]) | |
.src({prepend: true}, 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