Skip to content Skip to sidebar Skip to footer

Handlebars Not Loading After Require.js Optimization With Grunt-requirejs

I'm using the Yeoman Backbone generator for my app. I wanted to use Handlebars for templates. When I include a shim, it works great in development with grunt serve. // main.js req

Solution 1:

Apparently I only had to set wrapShim to true in the build configuration in Gruntfile.

requirejs: {
    dist: {
        options: {
            baseUrl:'.tmp/scripts',
            optimize:'none',
            paths: {
                'templates':'../../.tmp/scripts/templates',
                'jquery':'../../<%= yeoman.app %>/bower_components/jquery/dist/jquery',
                'underscore':'../../<%= yeoman.app %>/bower_components/underscore/underscore',
                'backbone':'../../<%= yeoman.app %>/bower_components/backbone/backbone',
                'bootstrap':'../../<%= yeoman.app %>/bower_components/sass-bootstrap/dist/js/bootstrap',
                'handlebars':'../../<%= yeoman.app %>/bower_components/handlebars/handlebars'
            },
            preserveLicenseComments:false,
            useStrict:true,
            wrap:true,
            wrapShim:true
        }
    }
},

In fact, it picked up the shim configuration from main.js, so everything is great. Hopefully this helps someone out dealing with the same frustration.

Post a Comment for "Handlebars Not Loading After Require.js Optimization With Grunt-requirejs"