NextJS Preprocessor to support next export

Viewed 10

next export (which gives static html file) does not support i18n, as it will give the following error

Error: i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment

So that I wish to have two codes from same codebase. One version with translation (v1), one without (v2). Is it possible to have some kinds of preprocessor (like C++ preprocessor) to automatically remove the code for translation for v2?

for example in the code based below

import { IntlProvider } from 'react-intl'; 
...
    return <IntlProvider locale={locale} messages={messages} textComponent={Fragment}>
        <div>hello</div>
    </IntlProvider >;

V1 will have exactly the same code

V2 will have

...
return <div>hello</div>

after preprocessing (remove translation related part, import and the code)

Or is there a better method to achieve that?

0 Answers
Related