2015-08-20 54 views
1

我一直在與Ember 1.13玩弄,我可以看到,在一些在線教程,他們通過index.html的需要JS和CSS,而一些使用燼-CLI-build.js或brocfile.js舊版本。我覺得它需要適當的時候我用燼-CLI-build.js但當時我不知道究竟是什麼用途的index.html需要外部js和css庫在燼js的正確方法?

回答

2

這要看情況。

如果你有餘燼-CLI-插件將這些文件本身通常添加到供應商的文件。與ember-cli-materialize一樣。

如果你像Ladda安裝隨機涼亭包,你需要手動添加您需要的文件餘燼-CLI-build.js:

module.exports = function(defaults) { 
    var app = new EmberApp(defaults, { 
    }); 

    app.import('bower_components/ladda/dist/ladda-themeless.min.css'); 
    app.import('bower_components/ladda/dist/spin.min.js'); 
    app.import('bower_components/ladda/dist/ladda.min.js'); 

    return app.toTree(); 
}; 

這將被合併到您的供應商。 css和vendor.js鏈接到index.html。

此外,當您構建應用程序的bower_components將無法​​使用,除非你明確包括的東西,所以你不能僅僅從index.html的鏈接到他們。單獨包含文件也會浪費網絡資源。除非是外部資源,否則不應在index.html中包含任何內容。

brocfile.js燼-CLI-build.js,因爲他們已經用西蘭花停下舊名稱。只需使用較新的一個。