导入CSS文件样式。返回空对象。似乎css-loader没有正确工作。有人能帮我吗?请在下面找到参考文件。
index.js
index.js
import React from 'react'
import style from './header.css'
console.log(style) // Returning empty object
export default class Header extends React.PureComponent {
render() {
return(
<header className = {style.header}>
This is header component
</header>
)
}
}
./header.css
.header {
background: #007DC6;
}
./webpack.config.js
{
test: /\.css$/,
exclude: /node_modules/,
loaders: ['style-loader', 'css-loader'],
}, {
test: /\.css$/,
include: /node_modules/,
loaders: ['style-loader', 'css-loader'],
}
loaders: ['style-loader', 'css-loader?modules=true&camelCase=true']
。 - Gopinath Shiva