fwouts / viteshot

Viteshot 📸 is a fast and simple component screenshot tool based on Vite.
https://viteshot.com
MIT License
214 stars 12 forks source link

[FR] Provide an async setUp function running on node #71

Open sk- opened 2 years ago

sk- commented 2 years ago

In order to configure our i18n with next-i18next we had to first run a script to generate a JSON file, which we then load and pass it as props to our Wrapper component.

The wrapper looks something like:

// This is the generated file
import localeTable from "../build/locale-table-en.json";

export const Wrapper: React.FC = ({ children }) => {
  const TranslatedApp = appWithTranslation(() => <>{children}</>);
  return (
    <TranslatedApp
      pageProps={localeTable as any}
      router={{ locale: "en", route: "/" } as any}
      Component={null as any}
    />
  );
};

The solution works, but it was not easy to figure it out and also has the drawback that we now have to run a build step before taking the screenshots.

It'd be great if there was some kind of setUp running on node or even something like getStaticProps from NextJS.