Is Ember CLI detached from CDN?

Downloading my ember CLI application currently includes downloading a 3Mb file, most of which consists of shared libraries like jquery, ember, bootstrap, etc. 3Mb is not huge, but it becomes noticeable by a slow connection, so I want to remove from all shared libraries and get them from the CDN. The idea is that they will be cached by the browser so that they do not need to be reloaded every time I update my application (which is very common at the moment). I read this question which indicates that it is easy to simply add <script...> to index.html, but I cannot figure out how to tell ember not to package these libraries in vendor.js.

+5
source share
3 answers

In brocfile.js ( ember-cli-build.js in new versions) change the constructor to

 var app = new EmberApp({ vendorFiles: { 'jquery.js': false, 'handlebars.js': false, 'ember.js': false } }); 

Now include the ones in your index.html, the old way, and enjoy the fact that almost every user browser already has jquery cached, even if they haven't visited your site before.

+6
source

docs usually have the answer for this:

You need to install Bower, a package manager that supports your external interfaces (including jQuery, Ember, and QUnit). It is as simple as running:

If you check your bower.json file, you will find jquery and all other libraries, bower delete them, and you're done.

-1
source

This is what you get by default with ember-cli. From the manual :

When the environment will be produced (for example, ember build --environment=production ), the addon will automatically print your js, css, png, jpg and gif assets, adding the md5 checksum to the end of its file name (for example, assets/yourapp-9c2cbd818d09a4a742406c6cb8219b3b.js ) In addition, your html, js and css files will be overwritten to include the new name.

You can then modify your Brocfile.js to tell it which base url for your cdn is:

prepend - Default value: '' - a string for adding all assets. Useful for CDN URLs such as https://subdomain.cloudfront.net/

-1
source

Source: https://habr.com/ru/post/1204794/


All Articles