我使用create-react-app创建了一个应用程序。我通过配置webpack文件来使用CSS模块。当我使用reactstrap Bootstrap类出现但样式不适用。
遵循https://reactstrap.github.io/的指示
也在index.js文件中导入CSS,但样式不适用。
{
test: /\.css$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
modules: true,
localIdentName: '[name]__[local]__[hash:base64:5]'
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
],
},
我尝试导入'!style-loader!css-loader!bootstrap / dist / css / bootstrap.css'; https://github.com/reactstrap/reactstrap/issues/778
但它会引发一个错误。'符合预期的符号!'
我使用Bootstrap CSS作为CDN解决了问题。