Skip to content

Commit

Permalink
Merge pull request #16 from SectorLabs/add-option-to-uglify-catalogs
Browse files Browse the repository at this point in the history
Add option to uglify catalogs
  • Loading branch information
Toader Mihai authored Jul 22, 2020
2 parents e8e1bc3 + 2b29147 commit 897e804
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist/lingui-multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const compile = require('@sector-labs/lingui-cli/api/compile')
const commander = require('commander')
const extract = require('@sector-labs/lingui-cli/api/extract')
const tmp = require('tmp')
const uglifyJS = require("uglify-js")

const path = require('path')
const fs = require('fs')
Expand Down Expand Up @@ -37,6 +38,7 @@ commander
.option('-s, --strict', 'Strict compilation')
.option('--removeIdentityPairs', 'Reduces the catalog size by removing the entries that have a translation identical with the translation')
.option('--targetFolder <folder>', 'The path where to store the compiled catalogs. Defaults to [localesFolder]')
.option('--uglify', 'Uglify catalogs')
.action(function(packageFile = './package.json', localesDir = './locale', args = {}) {
try {
// 1. Load the config from package.json
Expand Down Expand Up @@ -165,7 +167,7 @@ const compileCatalogs = (packageObject, localesDir, locales, args) => {
getCatalogTargetFilePath(args.targetFolder || localesDir, locale) :
getSubCatalogTargetFilePath(args.targetFolder || localesDir, locale, catalogName)

fs.writeFileSync(targetFile, jsData)
fs.writeFileSync(targetFile, args.uglify ? uglifyJS.minify(jsData).code: jsData)

console.info(`${locale} ${Object.keys(screenedCatalogObject).length}`)
})
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"dependencies": {
"@sector-labs/lingui-cli": "2.7.3-sl.19",
"commander": "^2.15.1",
"tmp": "^0.2.1"
"tmp": "^0.2.1",
"uglify-js": "^3.10.0"
},
"files": [
"LICENSE",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,11 @@ typescript@^2.9.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==

uglify-js@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.0.tgz#397a7e6e31ce820bfd1cb55b804ee140c587a9e7"
integrity sha512-Esj5HG5WAyrLIdYU74Z3JdG2PxdIusvj6IWHMtlyESxc7kcDz7zYlYjpnSokn1UbpV0d/QX9fan7gkCNd/9BQA==

wcwidth@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
Expand Down

0 comments on commit 897e804

Please sign in to comment.