Is there a way to import json as a static file?
See original GitHub issueI’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:
- Created 6 years ago
- Reactions:24
- Comments:48 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@devongovett For example, I want to lazy load some (or a lot) json data.
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.