2

In an Ember CLI app. If one wanted to use https://github.com/twbs/bootstrap/blob/master/js/tooltip.js

http://www.ember-cli.com/ does not seem to mention anything specific about this.

Where would this file typically be stored? At first glance, I was thinking of putting it in public/assets/js. What is the convention, if any?

Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215
  • http://stackoverflow.com/questions/23349959/recommended-way-to-include-bootstrap-library-in-ember-js-ember-cli-app or use an addon https://www.npmjs.com/package/ember-cli-bootstrap – blessanm86 May 22 '15 at 13:11

2 Answers2

7

Yes there is a convention. Use bower if a package exists. If it doesn't, download the repo into the vendor folder. Import the file in your Brocfile.js

app.import('vendor/path_to/main_js_file.js');
mistahenry
  • 8,554
  • 3
  • 27
  • 38
  • So they go in `vendor/` and not `public/`? Don't assets in `public/assets` get compiled to `vendor` anyways? On that thought, would it be fine storing them directly in `public`? – Christian Fazzini May 22 '15 at 14:42
  • Go to http://www.ember-cli.com/, scroll to folder Layout, and peep this line: `vendor/ Your external dependencies not installed with Bower or Npm.` Also, `vendor.js` is different from this folder. – mistahenry May 22 '15 at 14:46
  • Oh sweet. Must have missed that! – Christian Fazzini May 22 '15 at 14:53
  • You say use bower if package exists, but most plugin developers also provide npm packages. So what is the way to install/consume npm packages ? – copenndthagen Nov 23 '15 at 09:27
  • @testndtv `npm install` in a `ember-cli` app from proj base directory will put the packages into the `node_modules` directory by default. If the package is an ember addon, it will automatically be imported into the app. If it isn't, use the same `app.import`. But most npm packages I've ever used are server side utils, and bower generally has the client side libraries. Obvs not always the case but in 20+ external libs in my current proj, not one client side is installed via bower except the Ember addons. – mistahenry Nov 23 '15 at 18:37
0

Yes, use bower or place them in vendor/. Then register them in ember-cli-build.js

Here's the documentation: https://guides.emberjs.com/v2.14.0/addons-and-dependencies/managing-dependencies/

Rimian
  • 36,864
  • 16
  • 117
  • 117