UNPKG

lynx-intlayer

Version:

A Lynx plugin for seamless internationalization (i18n) and localization (l10n) of your mobile app.

44 lines (42 loc) 1.4 kB
import { prepareIntlayer, watch } from "@intlayer/chokidar"; import { getAlias, getConfiguration, getProjectRequire } from "@intlayer/config"; //#region src/plugin/pluginIntlayerLynx.ts /** * A Lynx plugin to integrate Intlayer into the Lynx build process. * * - Loads the Intlayer configuration and injects environment variables. * - If enabled, starts a file watcher for dictionary changes. * - On build, prepares the Intlayer configuration. * - Optionally checks for dictionary changes before compiling (hot reload). * * Usage in your lynx.config.ts: * * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginIntlayerLynx } from '@intlayer/lynx-plugin' * * export default defineConfig({ * plugins: [ * pluginIntlayerLynx(), * ], * // ...other configuration * }) */ const pluginIntlayerLynx = () => { return { name: "plugin-intlayer-lynx", async setup(api) { const configuration = getConfiguration(); await prepareIntlayer(configuration); if (configuration.content.watch) watch({ configuration }); api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => { return mergeRsbuildConfig(config, { resolve: { alias: { ...getAlias({ configuration }), react: getProjectRequire().resolve("@lynx-js/react") } } }); }); } }; }; //#endregion export { pluginIntlayerLynx }; //# sourceMappingURL=pluginIntlayerLynx.mjs.map