Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 5f1224e

Browse files
committed
Documentation and changelog updates for this work
1 parent 3ae866c commit 5f1224e

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v0.8.0
2+
3+
- Build will now substitute `empty:` for the right-hand side of
4+
`config/requirejs.yml` paths entries that are URLs.
5+
- Documented how to configure assets hosted on a CDN.
6+
17
# v0.7.3
28

39
- Upgrade RequireJS and r.js to v1.0.8

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,38 @@ This will generate a script tag like so:
186186
<script data-main="/assets/page1.js" data-foo="..." data-bar="..." src="/assets/require.js"></script>
187187
```
188188

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+
189221
## Troubleshooting
190222

191223
### Avoid `config.assets.precompile`
@@ -196,7 +228,9 @@ javascript_include_tag, and which is **never** referenced by the AMD codebase.
196228

197229
## Using AMD libraries
198230

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.
200234

201235
### jQuery
202236

0 commit comments

Comments
 (0)