dbashford / mimosa-require

AMD/RequireJS module for Mimosa browser development workflow tool
3 stars 3 forks source link

Handle common configs #9

Closed dbashford closed 11 years ago

dbashford commented 11 years ago

From dbashford/mimosa#137

Here's another interesting case: separating out your RequireJS configuration into a separate module. RequireJS has no problem with this; the app runs fine. But Mimosa currently warns you about every file that references one of the path dependencies, telling you that it cannot be found.

config.js

define({
    app_name: "MyExampleApp",
    urlArgs: "b=" + ((new Date()).getTime()),
    shim: {
        'ember': {
            deps: ['handlebars', 'jquery'],
            exports: 'Ember'
        },
        'jquery.ui': ['jquery']
    },
    paths: {
        'App': 'app/main',
        'models': 'app/models',
        'views': 'app/views',
        'controllers': 'app/controllers',
        'templates': 'app/templates',
        'routes': 'app/routes',
        /*libs*/
        'jquery': 'libs/jquery/1.9.0/jquery',
        'handlebars': 'libs/handlebars/1.0.rc.1/handlebars',
        'ember': 'libs/ember/1.0.0-pre.4/ember',
        'jquery.ui': 'libs/jquery.ui/1.9.2/jquery-ui-1.9.2.custom.min',
        'bootstrap': 'libs/bootstrap/2.2.2/js/boostrap',
        /*requirejs-plugins*/
        'text': 'libs/requirejs-plugins/text',
        'hbs': 'libs/requirejs-plugins/hbs',
        'domReady': 'libs/requirejs-plugins/domReady'
    },
    /*hbs plugin options*/
    hbs: {
        disableI18n: true,
        templateExtension: "html"
    }
});

main.js

(function(root){
    require(["config"], function(config){
        requirejs.config(config);
        require(["App", "ember"], function(App, Ember){
            var app_name = config.app_name || "App";
            root[app_name] = App = Ember.Application.create(App);
            App.deferUntilDOMReady();
        });
    });
})(this);