将require.js与requirejs api(r.js)一起使用以进行优化/缩小,并且需要重新组织我们的目录结构(因此,重新映射requirejs配置文件/ etc中的所有内容)。
目前尝试编译(通过节点)的结果是:
compiling js...<br />
/usr/local/www/site/build/node_modules/requirejs/bin/r.js:14174<br />
throw new Error(errorMsg);<br />
^
**Error: Error: Loader plugin did not call the load callback in the build: text**<br />
Module loading did not complete for: <br />
at Function.build.traceDependencies (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:15178:19)<br />
at build (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:14174:23)<br />
at requirejs.optimize.runBuild (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:15472:30)<br />
at Object.context.execCb (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:1692:33)<br />
at Object.Module.check (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:948:51)<br />
at Object.Module.enable.id (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:1181:34)<br />
at g (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:233:23)<br />
at Module.emit (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:1224:21)<br />
at each (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:165:31)<br />
at Object.Module.emit (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:1223:17)<br />
at Object.Module.check (/usr/local/www/site/build/node_modules/requirejs/bin/r.js:1002:30)<br />
构建呼叫是:
var requirejs = require('requirejs');
var config = {
baseUrl: './public/js',
mainConfigFile: './public/js/config/config.js',
paths: {
'requireLib': 'library/require'
},
out: "./public/js/minified/main.js",
name: "minified/main",
wrap: false,
preserveLicenseComments: false,
deps: ["../js/local/main","modules/movie","modules/theatre"]
};
requirejs.optimize(config);
配置文件是:
require.config({
paths: {
// JavaScript folders
libs: "library",
plugins: "plugin",
adminlibs: "../adminassets/js/plugins/ui",
// Libraries
jquery: "library/jquery",
jqcookie: "library/jquery.cookie",
jqui: "../adminassets/js/plugins/ui/jquery-ui-1.10.0.custom.min",
jqezmark: "library/jquery.ezmark",
jqcolor: "library/jquery.color",
underscore: "library/underscore-amdjs",
backbone: "library/backbone-amdjs",
chosen: "library/chosen.jquery",
moment: "library/moment",
// Plugins
text: "plugin/text",
async: "plugin/async",
datetimepicker: "../adminassets/js/plugins/ui/jquery.datetimepicker",
ajaxfileupload: "../adminassets/js/plugins/uploader/jquery.ajaxfileupload"
},
shim: {
'chosen': ['jquery'],
'jqcookie': ['jquery'],
'jqui': ['jquery'],
'jqezmark': ['jquery'],
'jqcolor': ['jquery'],
'jquifull' : ['jquery'],
'datetimepicker' : ['jqui'],
'ajaxfileupload' : ['jquery'],
'backbone': ['underscore','jquery']
},
// Initialize the application with the main application file
deps: ["local/main"]
});
不确定这里有什么问题。整个设置工作,直到我开始移动文件...但编译过程仍然找到它需要的所有文件...它只是遇到上面列出的回调错误。
答案 0 :(得分:0)
事实证明,更新我的requirejs,文本插件和r.js文件解决了这个问题。