README.md in requirejs-rails-0.7.3 vs README.md in requirejs-rails-0.8.0

- old
+ new

@@ -184,12 +184,54 @@ ``` <script data-main="/assets/page1.js" data-foo="..." data-bar="..." src="/assets/require.js"></script> ``` +### External domain (CDN) support + +There are two ways in which requirejs-rails supports the use of different +domains for serving built JavaScript modules, as is the case when using +a [CDN](http://en.wikipedia.org/wiki/Content_delivery_network). + +1. URLs in paths config in `requirejs.yml`: + + If requirejs-rails encounters an URL as the right-hand side of a paths + configuration, it will correctly emit that as `"empty:"` during the build + process so that [r.js will do the right thing](http://requirejs.org/docs/optimization.html#empty). + + Example: + + ```yaml + paths: + jquery: "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" + ``` + +2. Deploying all requirejs-rails assets to a CDN: + + In `config/environments/production.rb` (or another environment) + set the run_config as follows: + + ```ruby + config.requirejs.run_config['baseUrl'] = 'http://mycdn.example.com/12345abc/assets' + ``` + + The [`asset_sync` gem](https://github.com/rumblelabs/asset_sync) is one + tool that can be used to deploy your built assets to a CDN (S3, in this + case). + +## Troubleshooting + +### Avoid `config.assets.precompile` + +Don't set `config.assets.precompile` to reference any of your AMD module code. +Avoid it altogether, except to reference non-AMD code that you're loading via +javascript_include_tag, and which is **never** referenced by the AMD codebase. + ## Using AMD libraries -I currently recommend placing your AMD libraries into `vendor/assets/javascripts`. The needs of a few specific libraries are discussed below. +I currently recommend placing your AMD libraries into +`vendor/assets/javascripts`. The needs of a few specific libraries are +discussed below. ### jQuery jQuery users must use jQuery 1.7 or later (`jquery-rails >= 1.0.17`) to use it as an [AMD module](http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition) with RequireJS. To use jQuery in a module: