question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to import json as a static file?

See original GitHub issue

I’m using a few libraries that want to load json from a path. Is there a way to serve static files (similar to what the copy-webpack-plugin does)?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:24
  • Comments:48 (7 by maintainers)

github_iconTop GitHub Comments

29reactions
sunnylqmcommented, Jan 9, 2018

@devongovett For example, I want to lazy load some (or a lot) json data.

18reactions
stevagecommented, Jun 18, 2018

Just wanted to add my use case: loading Geojson files (that is, spatial data containing location information). It doesn’t make any sense to me to bundle that data. It would make the bundle enormous, and presumably all the loading would have to happen before the site displayed. (In my case I’m using mapbox-gl-js, which means I could pass the loaded geojson object, instead of a URL…but I’d prefer not to.)

Really surprised there isn’t a simple solution like, “anything in /static doesn’t get bundled” and can be loaded using XHR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Import JSON file as a Module - Bits and Pieces
Learn how to import JSON as a module using Import Assert, a TC39 Stage 3 feature. ... Next, consider importing the JSON file...
Read more >
How to import a JSON file in JavaScript (ES6 Modules)
To import a JSON file in JavaScript, make sure the `type` attribute on the script tag is set to `module`. Use an import...
Read more >
Correct way to import a static json file (public folder or api folder)
Put it anywhere you want and just import it into your component or page file. Then it's accessible anywhere in the file. No...
Read more >
Using Webpack file-loader to import static json file gives file ...
Yes, import is build time thing. So you must do multiple builds for each different runtimeConfig.json . But loading the file at runtime...
Read more >
Get JavaScript Objects from a JSON File | Pluralsight
JSON is a file format widely used for static storage and app config management with any of the frameworks and data servers. Any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found