React : CSS class name import not working

后端 未结 15 1619
轻奢々
轻奢々 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条回答
  •  猫巷女王i
    2020-12-31 20:52

    Don't you need to specify the file's extension like import classes from './layout.css';?

    Try to instal style-loader and css-loader packages. Then add to you webpack this:

    {
        test: /\.css$/,
        loaders: [
            'style-loader?sourceMap',
            'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
        ]
    }
    

    I got if from css-modules documentation and I hope it will help you to achieve what you need.

提交回复
热议问题