Ask A Question

Notifications

You’re not receiving notifications from this thread.

Integrating your own css doesn't work with Rails 7.1.2

bemsa asked in CSS

Hello,
I use Rails 7.1.2 and Ruby 3.0.2. I wanted to include my own css. It doesn't work. The following errors occur:

Sprockets::Rails::Helper::AssetNotFound in Pages#index
The asset "custom.css" is not present in the asset pipeline.

I've tried everything. It wasn't a problem with older Rails versions. I've already tried searching on the internet but it didn't help.I need your help.
Thanks in advance

Reply

@bemsa, I ran into the same issue and after going through a couple of articles online I was able to get it fixed.
If you are using esbuild do the following:

  1. make sure gem jsbundling-rails gem is in your Gemfile
  2. run bundle
  3. run rails javascript:install:esbuild
  4. Take note of the last instruction which says you should copy the script ... and paste it in your package.json file Your package.json file will look like this after pasting the script object { "name": "app", "private": true, "dependencies": { "@hotwired/stimulus": "^3.2.2", "@hotwired/turbo-rails": "^8.0.4", "esbuild": "^0.20.2" }, "scripts": { "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets" }, "version": "v1.22.19" }
  5. run bin/dev, this command will run esbuild and save your js assets in the /assets/builds/ directory , it also starts your webserver.

Hope this helps.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.