I was wondering what the recommended way is to run a script that generates some static XML files at build time. Ideally, those scripts should be ES Modules so code can be shared between those scripts and my Next / React application code.
I think I need to customize the Webpack config but I'm not sure how I can run code there that uses ES Modules (and not just uses require).
EDIT: I have something like this in mind, which should also work with Modules:
{
webpack: (config, { isServer }) => {
if (isServer) {
require('./scripts/generate-xml');
}
return config;
}