Optimize

This library provides the following features:

  • AOT translation file flattening

  • Removal of translator comments

  • JSON file minification

Installation

pnpm add @jsverse/transloco-optimize --save-dev

Usage

  1. Make the optimizer run after building

Create the following task in your project.json configuration file:

{
  "name": "my-app", 
  ...,
  "targets": {
    "transloco:optimize": {
      "command": "transloco-optimize {workspaceRoot}/dist/my-app/assets/i18n"
    }
  }
}

  1. In your Transloco configuration, add the following setting:

provideTransloco({
  config: {
    flatten: {
      aot: !isDevMode()
    }
    ...
  },
}),

Alternatively, if you have some custom pipeline, you can just import it as a function:

import translocoOptimize from '@jsverse/transloco-optimize';

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

Last updated

@ 2024 Transloco