从 css 文件导入样式。返回空对象。似乎 css-loader 工作不正常。谁可以帮我这个事。请在下面找到参考文件
索引.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'],
}