Adding external js and css files in ember-cli

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

Place them in your ember-cli-build.js file, like this: itp/ember-cli-build.js at master · iamdtang/itp · GitHub

2 Likes

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

1 Like

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.

1 Like

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,

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

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.