I faced a similar problem with the Bootstrap 4 Ruby Gem for Rails https://github.com/twbs/bootstrap-rubygem. Its instruction also contains the phrase:
Then, remove all the *= require and *= require_tree statements from
the Sass file. Instead, use @import to import Sass files.
Do not use *= require in Sass or your other stylesheets will not be
able to access the Bootstrap mixins and variables.
Here's a contradiction.
If I do what they tell me to - this means that I loose the opportunity to cancel bundling all my (s)css
-files into a single application.scss
(and a single application.css
in the browser) while at the development stage. If I manually import all my scss-files inside application.css
- that means that I inject each file's content into a bigger one and Sprockets has no longer control over such bundling - as I do it manually. And I don't like it - at the development stage as I can't clearly see which css
-file this style came from.
So I chose another option - I left the application.css
untouched, then I created a bootstrap_code.scss
file (failed to name it bootstrap.scss
as it confused Rails) with a @import "bootstrap";
directive inside and finally I created some z.scss
file for my own styles - just to make sure they would come up AFTER the same bootstrap styles.
Of course, my solution has such a drawback that my scss
-files can not
access the Bootstrap mixins and variables
(because Sprockets converts them into css
giving them no chance to dive into Bootstrap scss
first), but since I need just a plain css
from Bootstrap that's OK for a moment.
Of course at the production stage I can return to the recommended approach described in the gem documentation ("remove all the *= require ...") should I really need the Bootstrap mixins and variables (something I usually do not need).