Skip to content

Commit f28ea82

Browse files
authored
Add a note about using asset pipeline assets (#140)
* Add a note about using asset pipeline assets * Rewrite note about using assets from the pipeline Clarify how it works so readers don't have to open the Sprockets PR. Also remove any mention of how it used to work, this should be an evergreen README comment.
1 parent ddd757a commit f28ea82

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ A fix for this has been proposed upstream at https://github.com/tailwindlabs/tai
9393
apk add build-base gcompat
9494
```
9595

96+
### Using asset-pipeline assets
97+
98+
In Rails, you want to use [assets from the asset pipeline to get fingerprinting](https://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark). However, Tailwind isn't aware of those assets. To use assets from the pipeline, use `url(image.svg)`. [Since Sprockets v3.3.0](https://github.com/rails/sprockets-rails/pull/476) `url(image.svg)` will then automatically be rewritten to `/path/to/assets/image-7801e7538c6f1cc57aa75a5876ab0cac.svg`. So the output CSS will have the correct path to those assets.
99+
100+
```js
101+
module.exports = {
102+
theme: {
103+
extend: {
104+
backgroundImage: {
105+
'image': "url('image.svg')"
106+
}
107+
}
108+
}
109+
}
110+
```
111+
112+
The inline version also works:
113+
114+
```html
115+
<section class="bg-[url('image.svg')]">Has the image as it's background</section>
116+
```
96117

97118
## License
98119

0 commit comments

Comments
 (0)