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

GroupBy pattern : files are not merged when a space exist in pattern #59

Open julienboulay opened 4 years ago

julienboulay commented 4 years ago

I faced an issue regarding pattern, when a space exist in the pattern definition : These groupBy definitions will not work, because of the spaces, after the coma, or at the end of the pattern

groupBy: [
  {
      pattern: '{../../libs/sdk/src/resources/i18n/**/en.json, ./src/resources/i18n/**/en.json}',
      fileName: 'resources/i18n/en.json'
  }
]
groupBy: [
  {
      pattern: '{../../libs/sdk/src/resources/i18n/**/en.json,./src/resources/i18n/**/en.json }',
      fileName: 'resources/i18n/en.json'
  }
]

When writing the pattern, I felt as if it was a json object... when it's not. Is it possible to define the pattern as a string or an array of string, to avoid this kind of errors ?

groupBy: [
  {
      pattern: ['../../libs/sdk/src/resources/i18n/**/en.json', './src/resources/i18n/**/en.json'],
      fileName: 'resources/i18n/en.json'
  }
]
tettusud commented 4 years ago

@julienboulay , its handled by external package glob, it expects a string rather than an array of object. What I am planning to do is to sanitize the string (remove any spaces), do you think it makes sense? so that I dont break any existing code .

julienboulay commented 4 years ago

Hi @tettusud,

First, thank you for this great plugin. Yes, it make sense to keep the current behaviour and sanitize the string. It may also be very interesting to display a log message if no file corresponding to pattern was found.