Reputation: 1773
I am trying to import my css file and I keep getting this error. Cannot find module './style.css'
. I modified my webpack.config.js
with no luck. Please any guidance or help is appreciated. Yes, Home.js and style.css are in the same directory.
webpack.config.js
...module: {
rules: [
{
test: /.js$/,
loader: 'babel-loader',
include: path.join(__dirname, 'app'),
exclude: /node_modules/,
query: {
presets: ['es2015', 'react', 'stage-1']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}
]
}...
style.css
body {
background-color: #000000;
margin: 0px;
}
Home.js
import './style.css'
Upvotes: 0
Views: 46
Reputation: 186
According to doc this should work;
...module: {
rules: [
...
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader']
})
}
]
}...
Upvotes: 1