Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

Integrating your own css doesn't work with Rails 7.1.2

1
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

@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.

Join the discussion
Create an account Log in