Adding external js and css files in ember-cli


#1

Hi,

I wish to add external js and css files to ember-cli project, is it possible to put this files some where say vendor folder and import it in index.html etc… rather than add-on approach

Regards Nagendra


#2

Place them in your ember-cli-build.js file, like this: https://github.com/skaterdav85/itp/blob/master/ember-cli-build.js


#3

Few more approaches are outlined at How to include folder of assets into ember app with ember cli


#4

Anything you put in /public ends up in the /dist folder and then can be included via your html document (index.html, or whatever it may be). I don’t understand the use of broccoli-funnel here.


#5

What about adding files that are externally hosted? They aren’t in /vendor … so do you just use app.import(‘https://…’) in the ember-cli-build file?

I tried that and get this error:

Build failed. The Broccoli Plugin: [SourceMapConcat: Concat: Vendor /assets/vendor.js] failed with: Error: ENOENT: no such file or directory,


#6

I wasn’t able to get this to work. Ember server returns an error: The Broccoli Plugin: [SourceMapConcat: Concat: Vendor /assets/vendor.js] failed with: Error: ENOENT: no such file or directory


#7

I don’t either, and it seems that’s because it just doesn’t work that way. Apparently, ember-cli.build.js isn’t intended to be used like a bundler or dependency injector, I guess. You’d need an extension for bundling/minification, and add your compiled file to the public folder (works in a subfolder, too). I hope that makes sense.