React : CSS class name import not working

后端 未结 15 1614
轻奢々
轻奢々 2020-12-31 20:16

i have a

div in my react component and im importing some class name from a class css file, but the class name is not getting integrated to the main
15条回答
  •  青春惊慌失措
    2020-12-31 20:59

    I have noticed many reference to test: cssRegex block, though you may not have it in the webpack config. If the above is your case try to open webpack.config.dev.js and find block starting with test: /\.css$/, (row 160 in my case). Then add the following lines so final result looks like this:

      {
        test: /\.css$/,
        use: [
          require.resolve('style-loader'),
          {
            loader: require.resolve('css-loader'),
            options: {
              importLoaders: 1,
              modules: true,
              localIdentName: '[name]__[local]__[hash:base64:5]'
          },
       },
    

    This should enable css modules to work.

提交回复
热议问题