Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init doc"v9.0.025/06/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
intlayerMinify
intlayerMinify is a Vite plugin that minifies compiled dictionary JSON files during a production build. It strips all unnecessary whitespace and, when combined with intlayerPrune, optionally renames content field names to short alphabetic aliases (a, b, c, …) to further reduce bundle size.
The plugin is already included and configured automatically when you use intlayer(). You only need to register it manually if you are composing the plugin stack yourself.
Usage
Copy the code to the clipboard
// vite.config.tsimport { defineConfig } from "vite";import { intlayerMinify, intlayerPrune } from "vite-intlayer";import { createPruneContext } from "@intlayer/babel";const pruneContext = createPruneContext();export default defineConfig({ plugins: [ intlayerPrune(intlayerConfig, pruneContext), intlayerMinify(intlayerConfig, pruneContext), ],});Activation conditions
intlayerMinify is active only when all three of the following are true:
- The Vite command is
build(notserve/ dev). build.optimizeistrue(orundefined, which defaults totruefor builds).build.minifyistruein your Intlayer config.
It is automatically disabled when editor.enabled is true because the editor needs the full, human-readable dictionary content.
What gets minified
The plugin targets two dictionary locations (as resolved from intlayer.system):
dictionariesDir— static all-locale dictionaries (e.g..intlayer/dictionaries/*.json)dynamicDictionariesDir— per-locale dynamic dictionaries
Fetch-mode dictionaries (fetchDictionariesDir) are never minified because they are served from a remote API at runtime using their original field names. Renaming fields would create a mismatch between the server response and client-side property accesses.
Field-name mangling (property minification)
When intlayerPrune has analysed the codebase and populated pruneContext.dictionaryKeyToFieldRenameMap, intlayerMinify also renames content field names to short aliases. For example:
Copy the code to the clipboard
// before{ "key": "myDict", "content": { "title": "Hello", "description": "World" } }// after (with mangling){ "key": "myDict", "content": { "a": "Hello", "b": "World" } }The corresponding source-file property accesses are renamed by the Babel pass inside intlayerOptimize, so runtime behaviour is unchanged.
Internal Intlayer fields (nodeType, translation, etc.) are never renamed.
Edge-case dictionaries
Dictionaries flagged in pruneContext.dictionariesWithEdgeCases (structural anomalies detected during the prune phase) are skipped entirely — neither minified nor mangled — to avoid shipping broken data.
Qualified groups (collections / variants / meta records)
For dictionaries with a qualifierTypes array (collections, variants, and meta records), the plugin preserves the qualifierTypes array and the meta side-map verbatim. Only the content entries have their field names mangled. The composite keys (used for selector matching at runtime) are never touched.