我一直试图在我的生产环境中保存一些ajax调用。为此,我捆绑并缩小了一些脚本,但我正在努力使用select2,它是翻译文件。select2 + requirejs:无法捆绑i18n文件
我已经在built.js中包含了jQuery + bootstrap +(很多deps)+ select2 + select2 i18n文件,并设置了填充值(我不认为这是需要的)。
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'
]
}
});
然而,当我尝试了所有精缩资源我得到的控制台上的错误装入我的应用程序:
Uncaught TypeError: Cannot read property 'define' of undefined
在此线上:
(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()
几秒钟后等待SecondsTimeout expires:
Uncaught Error: Load timeout for modules: select2/i18n/pt-BR,select2/i18n/es,select2/i18n/en
应用程序运行良好,没有构建的文件。