Recommended way to include bootstrap library in Ember.JS ember-cli App

后端 未结 9 832
余生分开走
余生分开走 2020-11-28 21:18

I am trying to install properly Twitter Bootstrap in my current ember-cli project. I did install bootstrap with bower :

bower install --save bootstrap
         


        
9条回答
  •  伪装坚强ぢ
    2020-11-28 21:40

    BASH:

    bower install --save bootstrap
    

    Brocfile.js:

    app.import('vendor/bootstrap/dist/js/bootstrap.js');
    app.import('vendor/bootstrap/dist/css/bootstrap.css');
    

    The JS will be added to the app.js, which is linked by default, and the CSS will be added to assets/vendor.css, which as of May 14th, is also added by default.

    For reference: http://www.ember-cli.com/#managing-dependencies

    In response to @Joe's question surrounding fonts and other assets, I was unable to get the recommended app.import() method to work on the fonts. I instead opted for the merge-trees and static-compiler approach:

    var mergeTrees = require('broccoli-merge-trees');
    var pickFiles = require('broccoli-static-compiler');
    var extraAssets = pickFiles('vendor/bootstrap/dist/fonts',{
        srcDir: '/', 
        files: ['**/*'],
        destDir: '/fonts'
    });
    
    module.exports = mergeTrees([app.toTree(), extraAssets]);
    

提交回复
热议问题