Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a note about using asset pipeline assets #140

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ A fix for this has been proposed upstream at https://github.com/tailwindlabs/tai
apk add build-base gcompat
```

### Using asset-pipeline assets

To use assets from the asset pipeline one would normally use `asset-url`. This doesn't work with Tailwind, as the CSS is not processed with sass. Instead use `url(image.svg)`, [since Sprockets v3.3.0](https://github.com/rails/sprockets-rails/pull/476) the URL will automatically be rewritten. In Tailwind this looks like this:
Copy link
Contributor

@dixpac dixpac Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the URL will automatically be rewritten for me as a reader this is a bit too abstract, can we expand a bit on this so I don't have to open PR link to understand what rewritten means.


```js
module.exports = {
theme: {
extend: {
backgroundImage: {
'image': "url('image.svg')"
}
}
}
}
```

The inline version also works:

```html
<section class="bg-[url('image.svg')]">Has the image as it's background</section>
```

## License

Expand Down