Skip to main content

Optimize

This library will do the following things:

  • AOT translation file flatting
  • Remove translators comments
  • Minify the JSON file

Installation

npm install @jsverse/transloco-optimize --save-dev

Usage

Add to your package.json the following script:

package.json
"scripts": {
"transloco:optimize": "transloco-optimize dist/appName/assets/i18n",
"build:prod": "ng build --prod && npm run transloco:optimize",
}

Then, add the following config option to the application Transloco config object:

import {isDevMode} from "@angular/core";

translocoConfig({
flatten: {
aot: !isDevMode()
}
})

You can also use it as a function:

import translocoOptimize from '@jsverse/transloco-optimize';
import { task } from 'gulp';

// e.g: `${__dirname}/dist/${appName}/assets/i18n`;
const pathToLocales = ...

task('transloco:optimize', function(cb) {
translocoOptimize({ dist: pathToLocales }).then(cb);
});