Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css classes appears but style not applied -REACTSTRAP - CSS MODULES

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

like image 282
Dhananjayan Avatar asked Sep 05 '18 05:09

Dhananjayan


2 Answers

Try this:

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

Let me know if that helps.

like image 62
Sourav Badami Avatar answered Nov 19 '22 15:11

Sourav Badami


I solved problem by using Bootstrap CSS as CDN.

like image 27
Dhananjayan Avatar answered Nov 19 '22 16:11

Dhananjayan