alienfast / vite-plugin-i18next-loader

Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.
Other
42 stars 3 forks source link

Can't get HMR or any refresh to work #12

Closed kabforks closed 1 year ago

kabforks commented 1 year ago

Hello!

I'm trying to use this nice plugin. However, I cannot get any updates. The only thing that works, is to kill the vite server and do a hard refresh.

Package.json

{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.11.2",
    "vite-plugin-svgr": "^3.2.0"
  },
  "devDependencies": {
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "i18next": "^22.5.1",
    "react-i18next": "^12.3.1",
    "redaxios": "^0.5.1",
    "vite": "^4.4.3",
    "vite-plugin-i18next-loader": "^2.0.4"
  }
}

And my vite config:

import fs from "node:fs";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";

import react from "@vitejs/plugin-react-swc";
import i18nextLoader from 'vite-plugin-i18next-loader'

export default defineConfig({
  plugins: [i18nextLoader({ paths: ['./src/config/locales'] }), react(), svgr(), ],
  server: {
    https: httpsSettings,
    port: 5200,
  },
});

Any help would be greatly appreciated!

rosskevin commented 1 year ago

I'm not sure how to help you, perhaps turn up logging add some more console.log statements to the dist file in your local node_modules. It's pretty simple, this plugin gets called on all file changes and we just check that filename against the full list of files we load. If it matches, we do a full refresh. https://github.com/alienfast/vite-plugin-i18next-loader/blob/main/src/index.ts#L187