I have a React component that I am trying to import the css.
import './Example.css';
class Example extends Component {
return <div className="example-class">Example</div>
}
My file structure looks like this
build
-index.js
src
-index.js
-Example.css
My webpack.config.js looks like the following.
Currently everything builds, but the css doesnt appear to be getting picked up.
Can anyone see what I would need to do to access my classnames after build?
var path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'index.js',
libraryTarget: 'commonjs2'
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
exclude: /(node_modules|bower_components|build)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.css$/,
use: [ 'css-loader' ]
}
]
},
externals: {
'react': 'commonjs react'
}
};
context: path.resolve(__dirname, 'src')in the webpack code