Require.js +骨干优化 [英] Require.js + Backbone optimization
问题描述
下午好
我试图用r.js优化基于Require.js源$ C $ c和骨干,但在编译过程中,我发现了以下错误:
I'm trying to optimize a source code based on Require.js and Backbone using r.js but I'm getting the following error during the compilation :
Tracing dependencies for: main
Cannot optimize network URL, skipping: empty:.js
TypeError: Cannot read property 'normalize' of undefined
In module tree:
main
app
router
views/main_panel/event_details
helpers/template_manager
我的template_manager模块不会尝试访问任何'正常化'属性,所以我真的不明白那是什么意思。
这里的切入点,以我的应用程序还有require.js配置。
My template_manager module does not try to access any 'normalize' property so I don't really understand what is that supposed to mean. Here's the entry point to my application as well as the require.js configuration.
require.config({
paths: {
order: 'libs/requirejs-plugins/order',
text: 'libs/requirejs-plugins/text',
jQuery: 'libs/jquery/jquery',
Underscore: 'libs/underscore/underscore',
Backbone: 'libs/backbone/backbone',
templates: '../templates',
Sync: 'helpers/sync'
}
});
require([
'app',
'event_manager',
'order!https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
'order!libs/underscore/underscore-min',
'order!libs/backbone/backbone-min',
'helpers/objects_extension',
'helpers/date_extension',
'helpers/assets'
], function(App){
App.initialize();
});
应用程序本身或多或少遵循什么在本教程。
我app.build.js文件如下
The application itself more or less follows what's in this tutorial. My app.build.js file is as follow
({
appDir: "../",
baseUrl: "js",
dir: "../app-build",
modules: [
{
name: "main"
}
],
paths: {
order: 'empty:',
text: 'empty:',
jQuery: 'empty:',
Underscore: 'empty:',
Backbone: 'empty:',
templates: '../templates',
Sync: 'helpers/sync'
}
})
感谢您的帮助。
推荐答案
詹姆斯·伯克说:
正文插件需要通过加载器为它处理文本加载! depenencies。装载机的插件作为构建的一部分执行,以解决他们的资源。
The text plugin needs be loaded by the loader for it to process text! depenencies. Loader plugins are executed as part of a build to resolve their resources.
所以应该足以删除文本:空:从路径配置,只是留下不包括:中,因此不会在最终版本的结果包括在内。这里假设你有本地可用text.js通过优化读取。
So it should be enough to remove the text: "empty:" from the paths config, and just leave the excludes: in so it is not included in the final build result. This assumes you have text.js available locally to be read by the optimizer.
https://github.com/jrburke/r.js/issues/221
这篇关于Require.js +骨干优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!