שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Proxy and compiler bundled into intlayer(); added proxy option, compatCallers, routing.enableProxy"v9.0.025.6.2026
- "Init doc"v8.0.021.1.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
intlayer Vite Plugin
The intlayer plugin is the single entry-point for integrating Intlayer into a Vite application. Register it once and everything works out of the box: dictionary compilation, module aliases, dev-server watching, locale-routing middleware, and production build optimisations.
Usage
העתקת הקוד ללוח
Options
העתקת הקוד ללוח
IntlayerPluginOptions extends GetConfigurationOptions (see @intlayer/config) with the following additional fields:
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Option | Type | Default | Description |
|---|---|---|---|
compatCallers | CompatCallerConfig[] | [] | Extra caller patterns for compat-adapter packages (e.g. @intlayer/react-i18next). Passed to the field-usage analyser at build time. |
proxy | { ignore?: (req) => boolean } | undefined | Options forwarded to the bundled locale-routing proxy. Use ignore to exclude specific paths (e.g. API routes) from locale routing. |
All other options (override, configFile, …) are forwarded directly to getConfiguration().
Examples
Ignore API routes from locale routing
העתקת הקוד ללוח
With a custom config file path
העתקת הקוד ללוח
With compat-adapter callers
העתקת הקוד ללוח
What the plugin does
1. Dictionary preparation
Before the build starts (and once per hour in dev), intlayer calls prepareIntlayer to compile all .content.ts files into optimised JSON dictionaries stored in .intlayer/.
2. Module aliases
The plugin adds Vite resolve aliases so that import { myDict } from 'intlayer/dictionaries/my-dict' resolves to the compiled JSON file on disk. SSR builds use ssr.noExternal to ensure all @intlayer/* packages are bundled with aliases applied.
3. Dev-server watcher
In development mode a chokidar watcher is started. When a .content.ts file changes the dictionaries are recompiled and Vite's HMR propagates the update to the browser.
4. Bundled locale-routing proxy (v9+)
Since Intlayer v9 the intlayerProxy middleware is registered automatically inside intlayer(). It handles:
- Locale detection from URL prefix, cookies, and
Accept-Languageheader. - 301 redirects when the detected locale does not match the current URL.
- Internal URL rewrites so the framework sees the correct
[locale]route parameter.
The proxy is controlled by routing.enableProxy (default true) in your Intlayer config. To disable it completely:
העתקת הקוד ללוח
To customise proxy behaviour without a separate intlayerProxy() call, pass proxy options to the main plugin:
העתקת הקוד ללוח
See the intlayerProxy documentation for the full routing behaviour reference.
5. Bundled compiler (v9+)
When compiler.enabled is true and compiler.output is set in your Intlayer config, intlayer() registers intlayerCompiler automatically. The compiler extracts inline content declarations written directly inside component files and writes them to dictionaries at transform time. See intlayerCompiler documentation.
6. Build optimisations
During a production build the plugin adds:
- intlayerOptimize – Babel transform that rewrites
useIntlayer('key')→useDictionary(hash)and injects direct JSON imports. - intlayerPrune – removes unused content fields from dictionary JSON.
- intlayerMinify – compacts dictionary JSON and optionally mangles field names.
These are inactive in development mode.
Deprecated aliases
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Deprecated export | Replacement |
|---|---|
intlayerPlugin | intlayer |
intLayerPlugin | intlayer |
