'need for json loader in webpack 5

I want to import .geojson file extension just like .json files (I don't need any special parsing). as I seen in webpack docs:

Since webpack >= v2.0.0, importing of JSON files will work by default. You might still want to use this if you use a custom file extension. See the v1.0.0 -> v2.0.0 Migration Guide for more information

but when I switch documentation version to webpack 5, there is no more content about this solution.

what is best practice to have .geojson files without downloading any extra module



Solution 1:[1]

In webpack 5 we can use "Asset Modules" to load common files like "json", "png" etc. See for more info: https://webpack.js.org/guides/asset-modules/

The loader config for your case might looks like this:

{
    test: /\.geojson$/,
    type: 'json',
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Russell