requirejs optimizer doesn't generate '.js' version of the text resource

241 views Asked by At

In my project I use yeoman (1.0.6). In a fresh webapp copy installed requirejs-text plugin to include template.html.

main.js

require.config({
    paths: {
        jquery: '../bower_components/jquery/jquery',
        text: '../bower_components/requirejs-text/text'
    }
});

require(['jquery', 'text!../templates.html'], function ($, templates) {
....

After building and optimizing a whole project, I expect to have generated templates.js file instead of templates.html ( added "optimizeAllPluginResources: true" as described here )

Gruntfile.js ( won't paste all code, just optimization settings )

....
requirejs: {
    dist: {
        options: {
            baseUrl: '<%= yeoman.app %>/scripts',
            optimize: 'none',
            optimizeAllPluginResources: true,
            preserveLicenseComments: false,
            useStrict: true,
            wrap: true
        }
    }
},
....

After grunt 'build' task is completed I see that template.html content is in main.js and there is no generated templates.js file

After adding (also have to set in copy task to copy requirejs-text plugin form app to dir folder ):

stubModules: ['text'],
exclude: ['text!../templates.html'],

files are excluded as expected, but there is still no templates.js file. ( get an error as expected: XMLHttpRequest cannot load file:///...../dist/templates.html. Cross origin requests are only supported for HTTP. it works fine with local HTTP )

My question is: What settings am I missing to generate templates.js file with a requirejs optimizer?

p.s. googled, spent all day, tried more than wrote here.

Thank You in Advance

0

There are 0 answers