格式化过程中忽略特定的文件路径.Js消息提取



使用Create React App和TypeScript时,会在src目录中自动生成一个文件:react-app-env.d.ts。此文件似乎是支持此处讨论的图像导入所必需的:https://github.com/facebook/create-react-app/issues/6560.

使用"格式"时。JS,我使用以下命令提取消息:

yarn extract 'src/**/*.ts*' --out-file lang/en-GB.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'

但不幸的是,这导致了这个错误:

warning Error: Error processing file src/react-app-env.d.ts
Debug Failure. Output generation failed
Done in 9.64s.

我需要同时处理.ts和.tsx文件。我曾试图破解搜索模式以排除特定的文件名,但现在我完全被难住了,因为我不确定它的确切规格。

作为一种变通方法,我可以在提取之前删除文件,但这非常烦人!

只需在提取脚本中使用'src/**/!(*.d).ts*'模式,这将从src文件夹中排除所有.d.*文件。

您也可以执行formatjs extract --ignore='**/*.d.ts'

这是一个很好的搜索https://github.com/search?l=JSON&q=%22formatjs+提取%22&type=如果您对用法感到好奇,请编写代码。

我投了一个公关来更新文件。

最新更新