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.

Loading json files with webpack plugin

See original GitHub issue

I am using the webpack plugin and I am not sure what’s the right way to load json files.

I’ve added the json-loader plugin: but I get the following error:

Error: Cannot find module '/Library/WebServer/Documents/edge-rendering/node_modules/json-loader/index.js!/Library/WebServer/Documents/edge-rendering/node_modules/dojo/package.json'

Should I add something else to the webpack config or should I load it differently?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

odoecommented, Apr 30, 2018

I got this build without errors and it consoles the json correctly, but not sure it’s updating the app right.

// webpack.config.js
        test: /\.json$/,
        type: "javascript/auto",
        loader: 'json-loader',
        exclude: /node_modules/
// night.ts
import * as novaStyle from '../../basemap-styles/nova.json';

console.log("nova", novaStyle, "style");

Webpack 4 handles JSON natively, but since we have to go through the Dojo loader to process the file, things get tricky.

Let me know if that helps.

odoecommented, May 1, 2018

Yeah, I don’t know where type is doc’d. I just came across it in this issue


Read more comments on GitHub >

github_iconTop Results From Across the Web

json-loader - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Load static JSON file in Webpack - Stack Overflow
Webpack 2 uses json-loader by default for all .json files. You should remove the .json rule and you would import the JSON as...
Read more >
Tree shaking JSON files with webpack - LogRocket Blog
Webpack performs out-of-the-box tree shaking when compiling multiple JSON files into a single one. Here's how and why you should use it.
Read more >
Load a JSON File with ES6 Modules Implementation
In the webpack config file, the loader rule accepts the NPM package to load any of the JSON files in your app. One...
Read more >
merge-jsons-webpack-plugin - npm
This plugin is used to merge json files into single json file,using glob or file names. Latest version: 2.0.1, last published: a year...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found