@@ -186,6 +186,38 @@ This will generate a script tag like so:
186
186
<script data-main="/assets/page1.js" data-foo="..." data-bar="..." src="/assets/require.js"></script>
187
187
` ` `
188
188
189
+ # ## External domain (CDN) support
190
+
191
+ There are two ways in which requirejs-rails supports the use of different
192
+ domains for serving built JavaScript modules, as is the case when using
193
+ a [CDN](http://en.wikipedia.org/wiki/Content_delivery_network).
194
+
195
+ 1. URLs in paths config in `requirejs.yml` :
196
+
197
+ If requirejs-rails encounters an URL as the right-hand side of a paths
198
+ configuration, it will correctly emit that as `"empty:"` during the build
199
+ process so that [r.js will do the right thing](http://requirejs.org/docs/optimization.html#empty).
200
+
201
+ Example :
202
+
203
+ ` ` ` yaml
204
+ paths:
205
+ jquery: "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
206
+ ` ` `
207
+
208
+ 2. Deploying all requirejs-rails assets to a CDN :
209
+
210
+ In `config/environments/production.rb` (or another environment)
211
+ set the run_config as follows :
212
+
213
+ ` ` ` ruby
214
+ config.requirejs.run_config['baseUrl'] = 'http://mycdn.example.com/12345abc/assets'
215
+ ` ` `
216
+
217
+ The [`asset_sync` gem](https://github.com/rumblelabs/asset_sync) is one
218
+ tool that can be used to deploy your built assets to a CDN (S3, in this
219
+ case).
220
+
189
221
# # Troubleshooting
190
222
191
223
# ## Avoid `config.assets.precompile`
@@ -196,7 +228,9 @@ javascript_include_tag, and which is **never** referenced by the AMD codebase.
196
228
197
229
# # Using AMD libraries
198
230
199
- I currently recommend placing your AMD libraries into `vendor/assets/javascripts`. The needs of a few specific libraries are discussed below.
231
+ I currently recommend placing your AMD libraries into
232
+ ` vendor/assets/javascripts` . The needs of a few specific libraries are
233
+ discussed below.
200
234
201
235
# ## jQuery
202
236
0 commit comments