thur thur - 1 year ago 104
JSON Question

How can I generate or import multiple json files in one, with webpack?

I have multiple json files, and want to transform they to one simple json file and use

to require it, like this:

import dictionary from './distFile.json';






distFile.json should be:


How can I do that?

Or there is anyway to do something like that:

import dictionary from ['./file1.json','./file2.json'];

Answer Source

Make a third file that you require both files in.


import file1 from './file1.json';
import file2 from './file2.json';
export default { ...file1, ...file2 };

Then just import that file:

import combinedJson from './combined.js'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download