-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When using the preact-cli, importing po
files directly gives me ts and webpack errors.
TS:
typescript: Cannot find module 'src/assets/locales/en.po' or its corresponding type declarations.
npm run build
(comes with preact-cli)
[...]
X ERROR ./src/locales/en.ts
ERROR in ./src/locales/en.ts(3,22):
TS2307: Cannot find module 'src/assets/locales/en.po' or its corresponding type declarations.
This is using a locales/en.ts
based on the examples with its associated po file in assets/locales/en.po
.
import messages from "src/assets/locales/en.po";
import { createLocale } from "preact-localized";
export default createLocale(messages);
When adding some ignore comments, everything works!
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import messages from "src/assets/locales/en.po";
import { createLocale } from "preact-localized";
export default createLocale(messages);
Here is the preact.config.js that I am using (it may be handy to add an example for this - I'll open a PR if you're interested).
import CopyWebpackPlugin from 'copy-webpack-plugin';
import { resolve } from "path";
export default (config) => {
config.plugins.push(
new CopyWebpackPlugin({
patterns: [{
from: "*",
to: "src/assets/locales",
context: resolve(__dirname, "src/assets/locales")
}]
})
);
config.module.rules.push({
test: /\.po$/,
use: "react-localized-loader",
});
};
Is there a better way to include the definitions for po files?
Metadata
Metadata
Assignees
Labels
No labels