@yassidev/nuxt-directus 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "directus",
3
3
  "configKey": "directus",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1849,8 +1849,7 @@ function setupI18n(config, nuxt, logger) {
1849
1849
  i18nPrefix: config.i18n.prefix
1850
1850
  };
1851
1851
  const path = "directus/locales";
1852
- const watcher = chokidar.watch(resolve(nuxt.options.buildDir, path, "*.json"), { ignoreInitial: true });
1853
- codes.map((code) => {
1852
+ const result = codes.map((code) => {
1854
1853
  const { dst } = addTemplate({
1855
1854
  write: true,
1856
1855
  filename: join(path, `${code}.json`),
@@ -1858,14 +1857,19 @@ function setupI18n(config, nuxt, logger) {
1858
1857
  return JSON.stringify(Object.fromEntries(translations.map((translation) => [translation.key, translation.value])), null, 2);
1859
1858
  })
1860
1859
  });
1860
+ return { code, dst };
1861
+ });
1862
+ if (nuxt.options.dev && !nuxt.options._prepare) {
1863
+ const watcher = chokidar.watch(resolve(nuxt.options.buildDir, path, "*.json"), { ignoreInitial: true });
1861
1864
  watcher.on("change", async (filePath) => {
1862
- if (filePath !== dst) return;
1865
+ const code = result.find((i) => i.dst === filePath)?.code;
1866
+ if (!code) return;
1863
1867
  const translations = JSON.parse(readFileSync(filePath, "utf-8"));
1864
1868
  const done = await syncTranslations(code, translations, runtimeConfig);
1865
1869
  if (!done) return;
1866
1870
  logger.info(`Synced translations for locale: ${code}`);
1867
1871
  });
1868
- });
1872
+ }
1869
1873
  }
1870
1874
  nuxt.hook("i18n:registerModule", (register) => {
1871
1875
  const locales = codes.map((code) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yassidev/nuxt-directus",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "A Nuxt module for better integration with Directus CMS.",
5
5
  "repository": "yassilah/nuxt-directus",
6
6
  "license": "MIT",