我想将 React CSS 模块与 Bootstrap 一起使用。
首先,我使用create-react-app
命令创建了一个项目。然后,我使用 NPM 安装了 Bootstrap 4,并将其包含在我的 app.js 中,例如:
import 'bootstrap/dist/css/bootstrap.css';
我也确实npm eject
可以访问我的 Webpack 配置文件。
同时我想在我的 layout.js 文件中使用 CSS 模块,所以我去了 webpack.config.dev.js 并将模块更改为 true:
test: /\.css$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
modules: true
}
当我将模块更改为true
Bootstrap 时,CSS 显示不正确。如果我将模块更改为,false
则 Bootstrap 正在工作。任何想法?