Skip to content

If bootstrap is added with cssbundling-rails, CSS imports break #101

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
gonzric1 opened this issue Aug 12, 2022 · 3 comments
Closed

If bootstrap is added with cssbundling-rails, CSS imports break #101

gonzric1 opened this issue Aug 12, 2022 · 3 comments

Comments

@gonzric1
Copy link

gonzric1 commented Aug 12, 2022

I've created three different apps in last two days using css bundling, and can add external css with neither. It gives the same error whether I use rails new myapp --css bootstrap or run ./bin/rails css:install:bootstrap

I was able to reproduce the error on two other repos linked below, and on two separate machines.

Steps to reproduce:
ruby "3.1.2"
gem "rails", "~> 7.0.3", ">= 7.0.3.1"

  • Either run rails new myapp --css bootstrap or do css:install:bootstrap after rails new runs.
  • yarn add '@fortawesome/fontawesome-free
  • add @import '@fortawesome/fontawesome-free' to ./app/assets/stylesheets/application.bootstrap.scss
  • run rails assets:precompile or bin/dev or yarn build:css

get error:

$ sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules
Error: Can't find stylesheet to import.
  ╷
3 │ @import '@fortawesome/fontawesome-free'
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  app/assets/stylesheets/application.bootstrap.scss 3:9  root stylesheet

two repos with this setup at:
https://github.com/gonzric1/css_test_1
https://github.com/gonzric1/css_test_2

I'm also using asdf to manage ruby, in case that is relevant?

@sarmad90
Copy link

I'm facing a similar issue. But I don't see an application.css in app/assets/stylesheets/. This is the error I'm seeing:

The asset "application.css" is not present in the asset pipeline.

@Petercopter
Copy link

@gonzric1 You are using Yarn 3, I would guess, because I'm seeing the same error while trying to migrate to Yarn 3 from Yarn 1. It seems like you can bypass the error by not using plug and play.

The weird thing is that I only see it in the CI, not locally. I've gone through the upgrade multiple times and I cannot figure out why I only see it in the CI.

This is a similar issue #92

@dhh
Copy link
Member

dhh commented Jan 3, 2023

You need to reference the full path to the css you're including. Looking at @FortAwesome, I made it work with:

@import '@fortawesome/fontawesome-free/css/all'

The build:css step adds node_modules to the load path. You can see all the options with ls node_modules/@fortawesome/fontawesome-free/css/.

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

4 participants