6

I created an application using create-react-app. I am using CSS modules by configuring webpack files. when I use reactstrap Bootstrap classes appears but styling not applying.

Following instructions from https://reactstrap.github.io/

imported CSS in an index.js file too, But style not applying.

 {
            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',
                    }),
                  ],
                },
              },
            ],
      },

I tried import '!style-loader!css-loader!bootstrap/dist/css/bootstrap.css'; https://github.com/reactstrap/reactstrap/issues/778

But it throws an error.'unexpected symbol !'

enter image description here

3
  • could you please check with test:/\.(s*)css$/, ? Commented Sep 5, 2018 at 5:56
  • I tried It is not working... i update question with screenshot. @lsa4299 Commented Sep 5, 2018 at 5:59
  • refer this link, looks very easy -> medium.com/@victorleungtw/… Commented Sep 5, 2018 at 6:03

2 Answers 2

6

Try this:

Import Bootstrap CSS in the src/index.js file: import 'bootstrap/dist/css/bootstrap.min.css';.

Let me know if that helps.

Sign up to request clarification or add additional context in comments.

Comments

2

I solved problem by using Bootstrap CSS as CDN.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.