UNPKG

lynx-intlayer

Version:

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

1 lines 2.27 kB
{"version":3,"file":"pluginIntlayerLynx.mjs","names":[],"sources":["../../../src/plugin/pluginIntlayerLynx.ts"],"sourcesContent":["import { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport {\n getAlias,\n getConfiguration,\n getProjectRequire,\n} from '@intlayer/config';\nimport type { RsbuildPlugin } from '@rsbuild/core';\n\n/**\n * A Lynx plugin to integrate Intlayer into the Lynx build process.\n *\n * - Loads the Intlayer configuration and injects environment variables.\n * - If enabled, starts a file watcher for dictionary changes.\n * - On build, prepares the Intlayer configuration.\n * - Optionally checks for dictionary changes before compiling (hot reload).\n *\n * Usage in your lynx.config.ts:\n *\n * import { defineConfig } from '@lynx-js/rspeedy'\n * import { pluginIntlayerLynx } from '@intlayer/lynx-plugin'\n *\n * export default defineConfig({\n * plugins: [\n * pluginIntlayerLynx(),\n * ],\n * // ...other configuration\n * })\n */\nexport const pluginIntlayerLynx = (): RsbuildPlugin => {\n return {\n name: 'plugin-intlayer-lynx',\n\n async setup(api) {\n // Load the Intlayer configuration and format env variables for Lynx.\n const configuration = getConfiguration();\n\n await prepareIntlayer(configuration);\n\n // If file watching is enabled in Intlayer's config, start it.\n if (configuration.content.watch) {\n watch({ configuration });\n }\n\n // Merge Intlayer-specific environment variables and alias configuration.\n api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {\n return mergeRsbuildConfig(config, {\n resolve: {\n alias: {\n ...getAlias({ configuration }),\n react: getProjectRequire().resolve('@lynx-js/react'),\n },\n },\n });\n });\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,2BAA0C;AACrD,QAAO;EACL,MAAM;EAEN,MAAM,MAAM,KAAK;GAEf,MAAM,gBAAgB,kBAAkB;AAExC,SAAM,gBAAgB,cAAc;AAGpC,OAAI,cAAc,QAAQ,MACxB,OAAM,EAAE,eAAe,CAAC;AAI1B,OAAI,oBAAoB,OAAO,QAAQ,EAAE,yBAAyB;AAChE,WAAO,mBAAmB,QAAQ,EAChC,SAAS,EACP,OAAO;KACL,GAAG,SAAS,EAAE,eAAe,CAAC;KAC9B,OAAO,mBAAmB,CAAC,QAAQ,iBAAiB;KACrD,EACF,EACF,CAAC;KACF;;EAEL"}