javascript - Prevent optimization of text! and json! plugins on requirejs optimization tool -
i'm using following architecture multipage requirejs based application.: https://github.com/requirejs/example-multipage-shim
the repository explains how optimize application running r.js, command line tool used kind of task.
everything should work fine project modules have dependencies perform http request fetch data server (wich can text or json)
this because of jsons , templates used pages need server-side processed localization.
here basic example show i'm talking about:
define( function( require ){ var applang = require('json!/pagelang/login'), //(a) logintemplate = require('text!/template/login'), //(b) module = require('app/model/user'), //(c) ....
an http request made server localhost/pagelang/login returns json
{ "hash": "translated_value", ... }
the same applied template/template_name
where html it's ui translated user language returned server.
by running r.js attempts load locations existant directory directory on server, obviously, don't exist.
tracing dependencies for: app/main/login error: error: loader plugin did not call load callback in build: json: json!/pagelang/login: error: enoent, no such file or directory '/pagelang/login' module loading did not complete for: app/main/login
so, prevent command line tool optimizing text! , json! modules. possible?
i checked requirejs build settings didn't find solution problem. help? https://github.com/jrburke/r.js/blob/master/build/example.build.js
the json plugin uses if (( config.isbuild && (config.inlinejson === false || name.indexof(cache_bust_query_param +'=') !== -1)) || (url.indexof('empty:') === 0)) {
when optimiser runs have couple of options.
- add build config option
inlinejson: false
, - add
!bust
end of json require.require('json!/pagelang/login!bust')
, or - add path build config option
paths: { "/pagelang/login": "empty:" }
the text plugin uses if (config.isbuild && !config.inlinetext) {
, if (url.indexof('empty:') === 0) {
- set build config option
inlinetext: false
, or - add path build config option
paths: { "/template/login": "empty:" }
Comments
Post a Comment