我有一個相當大的應用程序,現在約5mb用於app.js和1mb +供應商js。我認爲它將跨越10MB,我們的目標用戶在慢速上網,並且每個用戶有不同的權利,因此大多數組件對用戶不可用。如何定製ember-cli構建以排除源代碼concat
我想從構建過程中排除一些大的組件,並根據需要加載它們。到目前爲止,我很喜歡這個想法https://github.com/Cryrivers/ember-remote-component/blob/master/app/components/remote-component.js,它檢查如果一個組件被加載,如果沒有則使用AJAX
加載它們像
if(!container.hasRegistration(`component:${ componentName }`)){
$.when(
$.getScript(`/remote-components/${ componentName }/component.js`),
$.getScript(`/remote-components/${ componentName }/template.js`)
).done(()=> {
let container = getOwner(this);
container.register(`component:${ componentName }`, require(`${ ENV.modulePrefix }/components/${ componentName }`).default, {singleton: false});
this.set('isLoaded', true);
})
}
我認爲這是可行的。但這裏有兩個問題
答:如何排除從構建過程的組成部分,並從串聯停止,但也讓他們在/距離/組件/ ABC/文件夾
B:在通過AJAX加載後編譯模板時,將該組件的template.hbs單獨編譯爲template.js將導致巨大的性能問題。
是的,感謝它已經降落在2.10和希望在2.12 LTS版本。那個時候我會更新到引擎...謝謝 –