tettusud / merge-jsons-webpack-plugin

This plugin is used to merge json files into single json file,using glob or file names
https://npmjs.com/package/merge-jsons-webpack-plugin
Apache License 2.0
36 stars 20 forks source link

Merging of files content if prefixFileName = false #52

Closed alexxlagutin closed 4 years ago

alexxlagutin commented 4 years ago

Hi there! Thank you for your plugin. It`s very useful! But I bumped into a problem. Hope you can help with it So I have a number of json files in folder and want to merge them

When I use prefixFileName = true i`m getting the result as

"parent" : { "child1" : {}, "child2" : {}, "child3" : {} }

But If i do prefixFileName = false data from children is merged (I have to say that data in files is similar)

What is expected: To get an Array of children instead of Object

tettusud commented 4 years ago

Ah I never thought about it, instead of prefixing it with file name, you simply need an array of coexisting (same) keys? May be you can create a gist with your sample data and expected result so it will be easier for me to work on

alexxlagutin commented 4 years ago

Hi! Thanks for the fast answer

I probably have to explain bit more about what I need to do and why Arrays are necessary

Right now I'm trying to use data from flat-files CMS as content of an application. I'm getting that content as number of folders, each of those folders has number of files with similar content. And I need to put them all to single file to be able to use them in different loops

I do this with your plugin in 2 steps. First one - is to group content from each folder to a single file with groupBy and pattern
2nd one - is to concatenate the result of step 1 into a singe file

step 2 works perfectly, but on the step 1 i'm getting result which I described in an issue

Here is a gist with data for step 1 https://gist.github.com/alexxlagutin/68f89cae748282f19104f94a04196132