LogoLogo
โค๏ธ SponserMore
  • ๐Ÿš€Getting Started
    • Installation
    • Angular Compatibility
    • Config Options
  • ๐Ÿ’กCore Concepts
    • Translation in the Template
    • Signals
    • Translation API
    • Language API
  • ๐Ÿง Advanced Topics
    • ๐ŸฆฅLazy Load
      • Scope Configuration
      • Inline Loaders
    • The Transpiler
    • SSR Support
    • Unit Testing
    • Hack the Library
  • ๐ŸงชSandbox & Examples
  • โš™๏ธAdditional Functionality
    • Loading Template
    • Key Referencing
    • Utility Functions
    • Comments for Translators
    • Multiple Languages Simultaneously
  • ๐Ÿ“ฆMigration Guides
    • Migrate from ngx-translate
    • Migrate from Angular's i18n
  • ๐Ÿ”งTools
    • Keys Manager (TKM)
      • Keys Extractor
      • Keys Detective
      • Options
      • Debugging
      • Using with Nx ๐Ÿ‹
    • Validator
    • Optimize
    • Scoped Library Extractor
  • ๐Ÿ”ŒPlugins
    • Message Format
    • Persist Translations
    • Persist Lang
    • Preload Langs
    • Locale l10n
    • Community Plugins
  • ๐ŸงฐSchematics
    • :ng-add
    • :scope
    • :join
    • :split
  • ๐ŸณRecipies
    • Prefetch User Language
    • Using Xliff
    • Generate Locale Files using Google Translate
  • ๐Ÿ“šBlog Posts
    • Transloco Team Posts
      • Transloco Goes Functional: A Guide to Transloco's Functional Transpiler
    • From the Community
  • โ“FAQs
Powered by GitBook

@ 2025 Transloco

On this page
  • Installation
  • Usage

Was this helpful?

  1. Tools

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
yarn add @jsverse/transloco-optimize --dev
npm install @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"
    }
  }
}

Add the following script to your package.json:

"scripts": {
  "transloco:optimize": "transloco-optimize dist/my-app/assets/i18n",
  "build:prod": "ng build --prod && npm run transloco:optimize"
}
  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 });
PreviousValidatorNextScoped Library Extractor

Last updated 4 months ago

Was this helpful?

๐Ÿ”ง