Skip to content

How to specify image or asset url in CSS #129

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

Closed
frogandcode opened this issue Jan 8, 2022 · 2 comments
Closed

How to specify image or asset url in CSS #129

frogandcode opened this issue Jan 8, 2022 · 2 comments

Comments

@frogandcode
Copy link

How does one specify the url of a background image (or other asset in the asset pipeline) in application.tailwind.css so that the asset url is generated properly?

With the sass-rails gem, I believe the following approaches work:

background-image: image-url(‘waves.png’);
// or
background-image: url(image_path(‘waves.png’));

I’ve tried both of these (along with asset_path) with tailwind-rails to no avail.

Has anyone done this in their application? Thanks!

@dhh
Copy link
Member

dhh commented Jan 9, 2022

url('waves.png') will be rewritten to use asset pipeline with latest sprockets-rails automatically 👍

@dhh dhh closed this as completed Jan 9, 2022
@connorgurney-me
Copy link

Just in case anyone ever comes back to this, make sure to restart your development server with ./bin/dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants