【发布时间】:2017-01-31 14:58:26
【问题描述】:
我一直在尝试在我的生产环境中保存一些 ajax 调用。为此,我捆绑并缩小了我的一些脚本,但我在 select2 和它的翻译文件上苦苦挣扎。
我在 build.js 中包含了 jQuery + bootstrap +(很多 deps)+ select2 + select2 i18n 文件并设置了 shim 值(我认为不需要)。
jquery 和 select2 都粘贴在 i18n 文件之前。
添加了以下配置(在生产环境中):
requirejs.config({
bundles: {
'built': [
'jquery',
'bootstrap',
'highcharts',
'bootbox',
'datatables',
'datatables-bootstrap',
'i18n',
'moment',
'knockout',
'knockout-mapping',
'pnotify',
'pnotify.nonblock',
'pnotify.desktop',
'pnotify.buttons',
'select2/select2',
'select2/i18n/pt-BR',
'select2/i18n/es',
'select2/i18n/en'
]
}
});
但是,当我尝试使用所有缩小的资源加载我的应用程序时,我在控制台上收到错误:
未捕获的类型错误:无法读取未定义的属性“定义”
在这一行:
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/pt-BR",[],function()
waitSecondsTimeout 过期几秒后:
未捕获的错误:模块加载超时: select2/i18n/pt-BR,select2/i18n/es,select2/i18n/en
应用程序在没有构建文件的情况下运行良好。
【问题讨论】:
标签: javascript jquery requirejs select2