So in webpack 2 when requiring/import a file import file from './file';
I got the following message:
You may need an appropriate loader to handle this file type.
This is because when requiring a file in [email protected] I used to have:
resolve: {
extensions: ['', '.js']
...
But it seems this is no longer accepted in webpack@2
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.resolve.extensions[0] should not be empty.
I have read migrating guide but I couldn't find it.
My loaders are as simple as that:
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
}
How do I fix it?
Thanks
this has been modified now in webpack2
now you have to provide only
resolve: {extensions: ['.js', '.ts','jsx','tsx']}
based upon the code syntax you choose
and if you provide '' in the array it throws an error
configuration.resolve.extensions[0] should not be empty
you can also provide ['*']
if you want to match all files.
In a newer Webpack Version you can't use an empty string. It says:
Getting error: configuration.resolve.extensions[0] should not be empty
.
You have to use extensions: ['.js']
or extensions: ['*', '.js']
.
Issue: https://github.com/webpack/webpack/issues/3043
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With