ERROR in ./src/index.js Module not found: Error: Can't resolve './style' in 'D:\gitcode\github\learn-webpack\demo15\src' @ ./src/index.js 8:0-17
Internet Solutions
1. Verify css-loader is mounted, and style-loader
npm install css-loader style-loader -D
2. Configure module.rules
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
}
My problems and solutions
My mistake was in fact an error occurred while configuring resolve.extensions, I configure became
extensions: ['js', 'css', 'json']
×
correct configuration is:
// webpack.config.js
module.exports = {
resolve: {
extensions: ['.js', '.css', '.json']
}
}
to sum up:
- resolve.extensions asked to write full extension, does not support without
.
wording. - Error prompt can not find the
./style
module, in fact, because the full complement configure the extension does not take effect.