From 45b842be3adeede677a52f3856c86943be829741 Mon Sep 17 00:00:00 2001 From: Alexander Kraus Date: Wed, 19 Feb 2020 14:29:20 +0100 Subject: [PATCH 1/2] Fix: No output JSON/Javascript files generated when using the compileTranslations feature. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index acfe66f..c442b51 100644 --- a/index.js +++ b/index.js @@ -43,6 +43,7 @@ AngularGetTextPlugin.prototype.apply = function(compiler) { results.forEach( (result) => { const { fileName, content } = result; const outPath = path.join(options.compileTranslations.outputFolder, fileName); + fs.writeFileSync(outPath, content); compilation.assets[outPath] = { source: function() { return content; From 4c9841b5271139ec062301fa5e85d39168101aa2 Mon Sep 17 00:00:00 2001 From: Alexander Kraus Date: Thu, 27 Feb 2020 16:25:37 +0100 Subject: [PATCH 2/2] if output path of translation compilation does not exist, it is created recursively. --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c442b51..c3309bd 100644 --- a/index.js +++ b/index.js @@ -42,8 +42,13 @@ AngularGetTextPlugin.prototype.apply = function(compiler) { const results = compile(options.compileTranslations); results.forEach( (result) => { const { fileName, content } = result; + var contentJSON = JSON.parse(content); + var unprefixedJSON = contentJSON[Object.keys(contentJSON)[0]]; + if(!fs.existsSync(options.compileTranslations.outputFolder)){ + fs.mkdirSync(options.compileTranslations.outputFolder, { recursive:true }); + } const outPath = path.join(options.compileTranslations.outputFolder, fileName); - fs.writeFileSync(outPath, content); + fs.writeFileSync(outPath, JSON.stringify(unprefixedJSON)); compilation.assets[outPath] = { source: function() { return content;