Helps Vite compile and resolve resx files.
A minimal vite.config.js
file enabling only this resolver should look like the following:
import { resx } from "@hejdoktor/vite-plugin-resx"
export default defineConfig({
plugins: [resx({ buildCommand: "npm run resx" })],
})
The buildCommand
passed in will be executed when a change in a .resx
file is detected, and should do the actual transformation.
The example buildCommand
is defined as following in the parent projects package.json
, using @hejdoktor/resx-compiler.
{
"scripts": {
"resx": "resx-compiler --default-locale en Client --pluralize"
},
"devDependencies": {
"@hejdoktor/resx-compiler": "^0.4.0"
}
}
The point of this resolver is to enable the following code:
import { R } from "./some-translations.resx"
console.log(R.someTranslatedFile)
Without this plugin, Vite will attempt to load some-translations.resx
file as javascript.
With this plugin, Vite will return some-translations.resx.ts
, which should be a compiled version of the translation file, instead.