我一直試圖在我的生產環境中保存一些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
應用程序運行良好,沒有構建的文件。