Reputation: 2759
I've a JSON file which I want to load in a Typescript class. Normally a syntax for that is
let json = require('file.json');
// Use of json file in TS class
This works perfectly fine under normal circumstances. But when I try to compile entire code with webpack, code doesn't work. I see the output code is replaced with following
var json = __webpack_require__(2);
This doesn't make much sense. Can somebody tell me what's going on under the hood and how to fix this issue?
Upvotes: 4
Views: 3636
Reputation: 13087
You need to configure WebPack to load JSON files.
https://github.com/webpack/json-loader
Upvotes: 1