我是r.js
优化新手,但喜欢requirejs
构建-config.js
({
appDir: "./src/main/webapp/webresources/javascript/",
baseUrl: "./",
dir: "./target/webresources/js",
optimizeCss: "none",
mainConfigFile: "./src/main/webapp/webresources/javascrip/app.js",
inlineText: true,
removeCombined: true,
modules: [
{
name: "app",
}
]
})
app.js看起来像
if (typeof _JSHome=== "undefined") {
_JSHome = "/webresources/javascript/edulastic";
}
if (typeof EditorValue === "undefined") {
EditorValue = "";
}
require.config({
baseUrl: '/webresources/javascript',
waitSeconds: 180,
paths: {
tpl : _JSHome+'/js/tpl',
underscore : 'underscore-min',
backbone : 'backbone-min',
text : 'text/text',
jquery : 'jquery',
jqueryuitouchpunch : "jquery.ui.touch-punch",
modernizr : 'modernizr',
hammer : 'hammer.min',
detectizr : 'detectizr',
bootstrap : _edulasticJSHome+'/bootstrap/js/bootstrap.min',
fastClick : "mobileutils/fastclick/fastclick.min",
asMetaData : _JSHome+'/js/app/metaData',
highCharts : '/webresources/javascript/highcharts/highcharts-min',
},
});
当我
r.js -o build-config.js
在项目根目录中运行时,出现以下错误:
尝试仅使用也是有效 JSON 的配置,或者不使用 mainConfigFile,而是将所需的配置值复制到构建文件或提供给优化器的命令行参数中。
解析的源错误:e:/mongrel_mpq/src/main/webapp/webresources/javascript/app.js: > ReferenceError: _JSHome 未定义
重复但没有解决方案 - Require.js 优化器和路径中的变量