I have an issue when trying to optimize client scripts that use client-side jade templating. Initially, I had an error as described in Require.js + Backbone optimization, but then I removed the “text” module from the paths configuration, added it to excludes and made text.js available locally. After doing that, I get an error where the optmizer tries to resolve the parameter being passed to the text module.
Here’s my client-side template:
define([
'Handlebars',
'text!/templates/product/something.jade'
], function(Handlebars, txtSomething) {
var template = Handlebars.template,
templates = Handlebars.templates = Handlebars.templates || {};
templates['something'] = Handlebars.compile(txtSomething);
});
And then the optimizer configuration:
({
baseUrl: ".",
name: "product",
out: "product.js",
paths: {
Handlebars: "empty:"
},
exclude: ["text"]
})
And the error I get:
Error: ENOENT, no such file or directory 'C:\templates\product\something.jade'
In module tree:
product
modules/something
templates/something
text
Any advice on how to resolve the issue?
I precompile the handlebars templates before running optimization. that removes the text references