Sha256: 03f251d704d9f16503f34a15c9448a46cf3431a6cfeac6392761bbacede0925c

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

## Rails assets

### Problem
When client js uses images in render methods, e.g. `<img src='...' />` or in css, e.g. `background-image: url(...)` 
these assets fail to load. This happens because rails adds digest hashes to filenames 
when compiling assets, e.g. `img1.jpg` becomes `img1-dbu097452jf2v2.jpg`. 

When compiling its native css Rails transforms all urls and links to digested 
versions, i.e. `background-image: image-url(img1.jpg)` becomes 
`background-image: url(img1-dbu097452jf2v2.jpg)`. However this doesn't happen for js and 
css files compiled by webpack on the client side, because they don't use 
`image-url` and `asset-url` and therefore assets fail to load.

### Solution

React on Rails creates symlinks of non-digested versions to digested versions when doing a Rails assets compile.
The solution is implemented using `assets:precompile` after-hook. The assets for symlinking
are defined by `config.symlink_non_digested_assets_regex` in `config/initializers/react_on_rails.rb`.
To disable symlinks set this parameter to `nil`.

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
react_on_rails-6.0.5 docs/additional-reading/rails-assets.md
react_on_rails-6.0.4 docs/additional-reading/rails-assets.md
react_on_rails-6.0.3 docs/additional-reading/rails-assets.md
react_on_rails-6.0.2 docs/additional-reading/rails-assets.md
react_on_rails-6.0.1 docs/additional-reading/rails-assets.md
react_on_rails-6.0.0 docs/additional-reading/rails-assets.md