-
Notifications
You must be signed in to change notification settings - Fork 202
Support hosted library importing #48
Conversation
Thanks for filing this issue. My initial take for this is to simply recognize any paths matching |
I started working on a patch for this last night, but had a difficult time figuring out the meaning of various variables (like the relationship between build_config and basConfig), where to put the logic for adding 'empty:' and where to put the logic for setting the path. In terms of my use case, I'd want it to be as simple as putting the following into requirejs.yml: paths:
jquery: https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js If you can help me understand the build_config method, I'd love to write some unit tests for it, so I can work on this in a TDD style. |
Second use case related to CDN support, from offline conversation with @stammy: The ability to specify baseUrl: "http://www.mybigcdn.com/192bac214/assets" Current design proposal is to allow |
Thanks @jwhitley -- I like your proposal for environment based requirejs.yml files. |
Are there other gems that follow the multiple config file approach? It seems too cluttered to me. I would suggest either allowing access to the configuration at runtime (so someone can use initializers for custom per-environment configuration), or allowing erb in the yml file so you can have some per-environment logic right in the yml file. |
"or allowing erb in the yml file so you can have some per-environment logic right in the yml file." My initial thought was to have a ruby initializer file so I can use my ENV vars that have my environment-specific CDN urls and so on. |
Completely agreed. ERB or config via an initializer it is. @btaitelb Thanks for the heads-up on To this end, a fair bit of effort in the gem has been to ensure that build configuration follows by-convention rules (e.g. buildUrl: "/assets") so that users can just run |
Only compute run_config on the first call, so that it can be inspected and modified by the application initializers.
@stammy @btaitelb I've just landed the CDN changes on |
This is great! It provides a nice simple interface to something that always felt a little hacky in requirejs. Thanks! |
Thanks for the feedback. This has just been released as @stammy Please let me know how the documented support for the everything-hosted-on-a-CDN works out for you. I haven't had the time to do ad-hoc testing with this, as I'm not currently setup for CDN publishing. If you don't get to it, I'll try to get |
@jwhitley awesome!! Will try to test it out tomorrow and report back. Yeah I'd test asset_sync with it too and push to our staging. |
Just like you can do "jquery" : "empty:" as a path in your r.js build file and then have the hosted url in your main.js (like https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js), I'd like to have requirejs-rails do that.
http://requirejs.org/docs/optimization.html#empty