1

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

simoncereska
  • 3,035
  • 17
  • 24
  • It seems to me the file is created after the grunt build, but you can't access it because you're accessing it from another origin? (localhost versus remote server? File versus localhost?) – thomaux Jan 13 '14 at 08:05
  • .js file is not created (what I actually need), .html is copied and I can't access it. – simoncereska Jan 13 '14 at 08:09
  • But the error you're getting is about the .html file. So somewhere in your code it is still referenced? – thomaux Jan 13 '14 at 08:18
  • Yes, if I understand correctly, it should include code something like define('text!../templates.html', [], function(require){ return require('../templates.js') }) in main.js and generate templates.js – simoncereska Jan 14 '14 at 09:12
  • same issue I cant get these .js file generated, did you finally found an answer? – arsenik Mar 14 '14 at 17:04
  • didn't solve it, simply require templates.js where I place all code I need. – simoncereska Mar 19 '14 at 19:50

0 Answers0