0

On build of this requirejs config using grunt-contrib-requirejs,

require.config({
            baseUrl : "js",
            shim    : {
                'ember' : {
                    deps :  ['handlebars', 'jquery'],
                    exports : 'Ember'
                },
                'bootstrap' : ['jquery'] ,
                'ember-data' : ['ember'],
                'handlebars' : {
                    exports : 'Handlebars'
                }
            },
            paths : {
                                /* APPLICATION  */
                'App' : 'app/ember-mock/app',
                'router' : 'app/ember-mock/router',
                'helper' : 'app/ember-mock/helper',
                'module' : 'app/ember-mock/module',
                'store' : 'app/ember-mock/store',
                                /* LIBRARIES */
                    *****
                    *****    //other  deps goes here
                    *****  


            },
            ****  //other options goes here
        });

        require([
               'App',
        'store',
        'router',****  //other requires goes here
         ], function(){
    });

my gruntfile.js file ,

module.exports = function(grunt) {
    'use strict';

    grunt.initConfig({
        pkg : grunt.file.readJSON('package.json'),
        requirejs : {
                        compile : {
                            options : {
                                baseUrl : 'js',
                                name : 'app/ember-mock/configuration/config',
                                mainConfigFile : 'js/app/ember-mock/configuration/config.js',
                                out : 'build/js/build.js',
                                optimize : 'uglify2',
                                inlintText : true,
                                findNestedDependencies : true
                            }
                        }
                    }

    });


    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.registerTask('default', [ 'requirejs' ]);

};

And my router.js file

define([ "App" ], function(EmberMockApp) {
    EmberMockApp.Router.map(function() {
        this.resource("app", {
            path : "/"
        });
        this.resource('home');
        this.resource('about');
        this.resource('blog');
        this.resource('connect');

    });
});

the router.js file is not traced as dependency by grunt-contrib-requirejs and skipped. Because of this no custom routers are registerd in ember app so emberjs is looking for default routes, so how to let grunt-contrib-require trace for router.js.

Bachan-user3143666
  • 343
  • 2
  • 5
  • 14
  • Could you show your grunt requirejs task and router declaration? – Andrew Shustariov Jan 23 '14 at 09:02
  • updated requirejs taks and router declaration, while grunt tracing the dependencies the router.js is skipped and not added to the build.js , so ember is looking for default routes like 'home.index' rather than 'home' route , More over the hbs.js is also skipped from the build.js file. build.js success without errors and is working . – Bachan-user3143666 Jan 23 '14 at 09:10
  • Try add return statement in router.js file, i. e. ```return EmberMockApp.Router...``` – Andrew Shustariov Jan 23 '14 at 11:26
  • No change but the router.js is loaded as this inline html – Bachan-user3143666 Jan 23 '14 at 11:39
  • And in console i am getting this error => Assertion failed: The attempt to link-to route 'home.index' failed. The router did not find 'home.index' in its possible routes: 'index', Uncaught Error: There is no route named home.index . showing search for default route rather than custom route – Bachan-user3143666 Jan 23 '14 at 11:47
  • The code is working fine when not optimized – Bachan-user3143666 Jan 23 '14 at 12:09
  • thanks @AndreyShustariov , I required the router.js instead of define and hence routes are registered in default by ember, Thanks for supporting .. – Bachan-user3143666 Jan 23 '14 at 12:56

0 Answers0