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

Rails7 Error: File to import not found or unreadable: bootstrap/scss/bootstrap. #243

Open
TangMonk opened this issue Oct 16, 2022 · 3 comments

Comments

@TangMonk
Copy link

image

@ychaker
Copy link

ychaker commented Nov 17, 2022

@TangMonk I'm pretty sure you only need to use @import "bootstrap"; to load all of the files or @import "bootstrap/variables";` to load a specific partial.

@ansonhoyt
Copy link

ansonhoyt commented Oct 19, 2023

@TangMonk I doubt this is a bug with this gem, so can this be closed?

I agree@import "bootstrap" should work, but I might be able to help...

You haven't given much detail, but perhaps you're using sprockets-rails for styles with jsbundling-rails for javascript? You may have installed the bootstrap nvm package to get Bootstrap's javascript, and are trying load that bootstrap.scss from Sprockets.

If so, I've seen this error, since doing that requires appending to the default asset search paths for Sprockets to look in ./node_modules:

# config/initializers/assets.rb
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
// app/assets/stylesheets/application.bootstrap.scss loaded with sprockets-rails
@import 'bootstrap/scss/bootstrap';

Should now work because Sprockets can now find this file:

$ file node_modules/bootstrap/scss/bootstrap.scss # sprockets adds the .scss extension for you
node_modules/bootstrap/scss/bootstrap.scss: ASCII text

The JavaScript would already be loading fine with jsbundling-rails, because it already looks in node_modules out of the box:

// app/javascript/application.js loaded with js-bundling-rails
import * as bootstrap from 'bootstrap'

@maxgronlund
Copy link

Hi @TangMonk,

I'm working on an open-source project and have been encountering similar issues while trying to integrate this engine: LoggableActivity, into this application: LoggableActivityDemoApp.

I keep getting this error: Error: File to import not found or unreadable: bootstrap/functions.

There's a link to a Slack channel for the project on this page: Loggable Activity Slack Channel.

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