I have /components/foo.js
and /pages/bar.js
, both are using <FormattedMessage />
with a different defaultMessage
:
// /components/foo.js export default function Foo() { return ( <FormattedMessage defaultMessage="Foo component" /> ); } // /pages/bar.js export default function Foo() { return ( <FormattedMessage defaultMessage="Bar page" /> ); }
If I run formatjs extract 'components/**/*.js' --out-file lang/en.json
I only get messages from my components folder. If instead I use the path pages/**/*.js
, I only get messages from my pages folder.
Tried a few differente combinations without luck:
(components,pages)/**/*.js
(components&pages)/**/*.js
(components|pages)/**/*.js
!(node_modules)/**/*.js
to compile everything except thenode_modules
folder.
Advertisement
Answer
It turns out that you need to use double pipe operator ||
.
formatjs extract '(components||pages)/**/*.js' --out-file lang/en.json