I use bootstrap css and an additional template written in less. Im import both in the root component of my react component. Unfortunately the styles from bootstrap overrule the less styles even if the less files are the second ones that are imported. Is there a way to ensure the order of the styles with webpack.
This is are the root component:
import React from "react";
import Dashboard from "./dashboard";
import 'bootstrap/dist/css/bootstrap.min.css'
import '../styles/less/pages.less'
React.render(
<Dashboard />,
document.body
);
this is there relevant part of the loader settings:
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
'css?sourceMap!' +
'less?sourceMap'
)
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
},
The problem is that I have to use the ExtractTextPlugin plugin also for the css part in my loader settings:
reorder your css import in index.js file:
note that
index.css
is loaded beforebootstrap.css
. they should be imported in following order: