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 @ngneat/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 { environment } from '../environments/environment';
{  flatten: {    aot: environment.production,  },};

You can also use it as a function:

import translocoOptimize from '@ngneat/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);});