Closed tomasbarrios closed 7 years ago
The bootstrap loader is only the webpack loader. It does not handle how you export the CSS. That can be either in your JS (default) or extracted via the extract-text-plugin.
These are the 2 places that you put your customizations. The difference with these is that if you want to use derived bootstrap variables, use the second place. If you want to set bootstrap variables that are used to derive other variables, use the first place.
# This gets loaded after bootstrap/variables is loaded
# So you can refer to bootstrap variables
bootstrapCustomizations: ./app/assets/styles/bootstrap-customizations.scss
# With CSS Modules we load all application styles directly in React components
# appStyles: ./app/styles/app.scss
Please request to re-open if this does not solve your issue.
I understand what you mean, that is why I am using the file for post customizations. I want to override bootstrap styles with this list
@import "~bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css";
@import "~bootstrap-social/bootstrap-social.css";
@import "~slick-carousel/slick/slick.css";
@import "~slick-carousel/slick/slick-theme.css";
The problem is that the bootstrap styles are loaded after the above styles. This is the order of the styles:
Loads vendor.js (ok) Loads bootstrap-customizations.scss (in seperate style tags) (ok) Loads bootstrap styles... (but after, it should be before!)
My goal is that they load like these:
Loads vendor.js Loads bootstrap styles... Loads bootstrap-customizations.scss (in separate style tags)
I think I probably misunderstood what bootstrap-customizations.scss is doing.
My final goal is to append a file where I override bootstrap styles. How should I do it?
Thanks.
I have this same problem - Even if I require('bootstrap-loader'); require('./my.css')
my css ends up being loaded before bootstrap, which means it doesn't work right.
This applies whether I'm using extract-text-webpack-plugin or not. No matter what, bootstrap-loader always puts my css first.
I ended up creating a new JS file just lo load css that should be loaded after. Add a new entry like ...
entry: {
// See use of 'vendor' in the CommonsChunkPlugin inclusion below.
vendor: [
'babel-polyfill',
'es5-shim/es5-shim',
'es5-shim/es5-sham',
'jquery',
],
rails: [
'./app/styleEntry.js'
],
app: [
'./app/bundles/Calendar/startup/calendarRegistration',
'es5-shim/es5-shim',
'es5-shim/es5-sham',
'babel-polyfill',
...
],
and then in styleEntry.js do something like these:
import "bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css";
import "bootstrap-social/bootstrap-social.css";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
You will have to explicitly include these new bundle in your rails asset file, e.g.
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*= require rails-bundle
...<require other rails gem stuff>
*= require_self
*= require_tree ./common
*/
Also, I had to modify the css loaders to these:
config.module.loaders.push(
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style',
'css?minimize&importLoaders=1' +
'!postcss'
),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css?minimize&importLoaders=3' +
'!postcss' +
'!sass' +
'!sass-resources'
),
},
// ... more loaders
);
Hi, I am facing an issue with bootstrap-loader.
When importing bootstrap, it adds the bootstrap css tag after what is in bootstrap-customizations.scss. And those are meant to override bootstrap variables.
As you can see in the picture above, Bootstrap styles are loaded last instead of first
bootstrap-customizations.scss
.bootstraprc