Skip to content

Instantly share code, notes, and snippets.

@NouranMahmoud
Created May 12, 2015 22:35
Show Gist options
  • Save NouranMahmoud/c4a216ea2695da6bf06a to your computer and use it in GitHub Desktop.
Save NouranMahmoud/c4a216ea2695da6bf06a to your computer and use it in GitHub Desktop.
requirejs = require('./node_modules/requirejs/bin/r.js')
baseConfig =
baseUrl: "./war/scripts/app"
locale: "en-us"
optimize: "uglify"
preserveLicenseComments: false
name: "almond"
findNestedDependencies: true
wrap: true
paths:
'almond': '../../vendor/almond/almond'
'text': '../../vendor/requirejs-text/text'
'jquery': '../../vendor/jquery/dist/jquery'
'bootstrap': '../../vendor/bootstrap/dist/js/bootstrap'
'underscore': '../../vendor/underscore-amd/underscore'
'backbone': '../../vendor/backbone/backbone'
'hbs': '../../vendor/require-handlebars-plugin/hbs'
'json2': '../../vendor/require-handlebars-plugin/hbs/json2'
'dataTables': '../../vendor/jquery.dataTables/media/js/jquery.dataTables'
'jquery.ui.widget': '../../vendor/blueimp-file-upload/js/vendor/jquery.ui.widget'
'jqueryIframeTransport': '../../vendor/blueimp-file-upload/js/jquery.iframe-transport'
'fileupload': '../../vendor/bootstrap-jasny/js/fileinput'
'bootstrapWizard': 'libs/jquery.bootstrap.wizard'
'moment': '../../vendor/momentjs/min/moment.min'
'kinvey': '../../vendor/kinvey/kinvey-backbone'
'async': '../../vendor/requirejs-plugins/src/async'
'geocomplete': '../../vendor/jquery-geocomplete/jquery.geocomplete.min'
'inputmask': '../../vendor/jquery.inputmask/dist/inputmask/jquery.inputmask'
'RestClient': '../../vendor/jquery.rest/dist/1/jquery.rest.min'
'scrollTo': '../../vendor/jquery.scrollTo/jquery.scrollTo.min'
'jqueryValidate': '../../vendor/jquery.validation/jquery.validate'
'date': '../../vendor/date/index'
'address': '../../vendor/x-editable/dist/inputs-ext/address/address'
'bootstrapEditable': '../../vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable'
'datepicker': '../../vendor/bootstrap-datepicker/js/bootstrap-datepicker'
'modernizr': '../../vendor/modernizr/modernizr'
'respond': '../../vendor/respond/respond.min'
'select2': '../../vendor/select2/select2.min'
'slider': '../../vendor/jquery.ui/ui/slider'
'domReady': '../../vendor/domReady/domReady'
'socketio': '../../vendor/socket.io-client/socket.io' #'async!http://104.155.15.183:3000/socket.io/socket.io'
shim:
'jquery':
exports: ['jQuery']
'underscore':
exports: '_'
'backbone':
deps: ['underscore', 'jquery']
exports: 'Backbone'
'kinvey':
deps: ['backbone']
exports: 'kinvey'
'bootstrap':
deps: ['jquery']
exports: 'bootstrap'
'dataTables':
deps: ['jquery']
exports: 'dataTables'
'jquery.ui.widget':
deps: ['jquery']
exports: 'jquery.ui.widget'
'jqueryIframeTransport':
deps: ['jquery']
exports: 'jqueryIframeTransport'
'fileupload':
deps: ['bootstrap']
exports: 'fileupload'
'bootstrapWizard':
deps: ['jquery', 'bootstrap']
exports: 'bootstrapWizard'
'moment':
exports: 'moment'
'geocomplete':
deps: ['jquery']
exports: 'geocomplete'
'inputmask':
deps: ['jquery']
exports: 'inputmask'
'RestClient':
deps: ['jquery']
exports: 'RestClient'
'scrollTo':
debs: ['jquery']
exports: 'scrollTo'
'jqueryValidate':
deps: ['jquery']
exports: 'jqueryValidate'
'date':
exports: 'date'
'address':
exports: 'address'
'bootstrapEditable':
deps: ['jquery', 'bootstrap']
exports: 'bootstrapEditable'
'datepicker':
deps: ['jquery', 'bootstrap']
exports: '$.fn.datepicker'
'modernizr':
exports: 'modernizr'
'respond':
exports: 'respond'
'select2':
exports: 'select2'
'slider':
deps: ['jquery']
exports: 'slider'
'domReady':
exports: 'domReady'
configs = [
{
include: ["login/login-module.js"]
out: "war/dist/scripts/login/login.min.js"
},
{
include: ["brands/brands-module.js"],
out: "war/dist/scripts/brands/brands.min.js"
},
{
include: ["product-types/product-types-module.js"],
out: "war/dist/scripts/product-types/product-types.min.js"
},
{
include: ["products/products-module.js"],
out: "war/dist/scripts/products/products.min.js"
},
{
include: ["promotions/promotions-module.js"],
out: "war/dist/scripts/promotions/promotions.min.js"
},
{
include: ["stores/stores-module.js"],
out: "war/dist/scripts/stores/stores.min.js"
},
{
include: ["categories/categories-module.js"],
out: "war/dist/scripts/categories/categories.min.js"
},
{
include: ["dashboard/dashboard-module.js"],
out: "war/dist/scripts/dashboard/dashboard.min.js"
}
]
# Function used to mix in baseConfig to a new config target
mix = (target) ->
for prop of baseConfig
target[prop] = baseConfig[prop] if baseConfig.hasOwnProperty(prop)
target
#Create a runner that will run a separate build for each item
#in the configs array. Thanks to @jwhitley for this cleverness
runner = configs.reduceRight((prev, currentConfig) ->
(buildReportText) ->
console.log buildReportText
requirejs.optimize mix(currentConfig), prev
, (buildReportText) ->
console.log buildReportText
)
#Run the builds
runner();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment