You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,15 @@ These configurations are configured via an option hash:
64
64
*`:digests` - Set a hash used for file name lookup. This will be default to Rails' manifest at `Rails.configuration.assets.digests`.
65
65
*`:prefix` - Set a path prefix of your assets file. This will be default to `Rails.configuration.assets.prefix` (usually at `/assets`.)
66
66
*`:manifest` - Set a path to your own manifest file to use for lookup. This will override both `:digest` hash and `Sprockets::Redirect.manifest` setting.
67
-
*`:asset_host` - Set the name of the host to use when serving assets. This is useful if you want your server to redirect to assets that are hosted on a CDN.
67
+
*`:asset_host` - Set the name of the host to use when serving assets. This is useful if you want your server to redirect to assets that are hosted on a CDN. You can also passing a `Proc` object which will be called on every asset requests to determine the host for that request:
68
+
69
+
config.middleware.swap Sprockets::Redirect,
70
+
Sprockets::Redirect,
71
+
:asset_host => Proc.new do |request|
72
+
if request.path =~ /\.min\.(js|css)\z/
73
+
"cdn.example.com"
74
+
end
75
+
end
68
76
69
77
You can swap out the middleware inserted automatically by the gem by using `config.middleware.swap` in your configuration file:
0 commit comments