Skip to content

Commit

Permalink
load dev scripts from a config json
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0uch authored and kleinsch committed Nov 21, 2013
1 parent 306eef7 commit 6af061e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ report/*
coverage/*
temp/*

ext.json
npm-debug.log
node_modules

Expand Down
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ module.exports = function(grunt) {
}
},


/*jshint multistr: true */
'compile-handlebars': {
dev: {
Expand All @@ -325,7 +326,8 @@ module.exports = function(grunt) {
MIXPANEL: '',\
GOOGLE_ANALYTICS: ''\
}\
}"
}",
ext: grunt.file.exists('./ext.json') ? grunt.file.read('./ext.json') : ''
},
output: 'build/dev.html'
},
Expand Down
16 changes: 7 additions & 9 deletions app/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,22 @@ Balanced.Auth = (function() {
auth.set('user', user);
auth.set('isGuest', isGuest);

this.addObserver('user.ext', this, function() {
var extensions = this.get('user.ext');
function loadExtensions() {
var extensions = ENV.BALANCED.EXT || this.get('user.ext');
if ( !! extensions && typeof extensions === 'object') {
for (var key in extensions) {
var script, src;
if ( !! ENV.BALANCED.DEBUG) {
// for testing in development
src = '//localhost:5555/dist/admin.bundle.js';
} else {
src = extensions[key];
}
src = extensions[key];
script = document.createElement('script');
script['data-package'] = key;
script.src = src + '?' + Math.floor(Math.random() * Math.pow(2, 8));
document.body.appendChild(script);
}
}
});
}

if ( !! ENV.BALANCED.EXT) { loadExtensions(); }
this.addObserver('user.ext', this, loadExtensions);
};

auth.rememberLogin = function(token) {
Expand Down
1 change: 1 addition & 0 deletions app/index.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<script type="text/javascript">
var ENV = {{{ env }}};
{{#if ext}}ENV.BALANCED.EXT = {{{ ext }}};{{/if}}
</script>

<script src="//d3nslu0hdya83q.cloudfront.net/dist/1.0/raven.min.js"></script>
Expand Down

0 comments on commit 6af061e

Please sign in to comment.