Importing geojson with react and next.js

Viewed 299

I am trying to load a geojson file into a react component that also uses next.js. When the extension is changed to json, it works fine. The problem is that with the geojson extension, it doesn't know how to handle the file. When I alter the next.config.js file as below, I get the error below.

module.exports = {
  webpack(config) {
    config.module.rules.push({
      test: /\.geojson$/,
      use: ["json-loader"]
    });

    return config;
  },
  devIndicators: {
    autoPrerender: false,
  },
}

And here is the error

Module not found: Can't resolve 'json-loader' in ...

How do I tell a next.js react app how to read in a new format?

0 Answers
Related