Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenient configuration #536

Closed
MrFoxPro opened this issue Dec 6, 2022 · 3 comments
Closed

Convenient configuration #536

MrFoxPro opened this issue Dec 6, 2022 · 3 comments
Labels
enhancement 🚀 New feature or request

Comments

@MrFoxPro
Copy link

MrFoxPro commented Dec 6, 2022

Thanks for your hard work on this handy tool.

Description

I want to make app with SSG/HTML-JS and SPA pages, so I don't need SSR output. But I can't configure exactly which steps I need.
My suggestion is to replace disableAutoFullBuild and prerenderer.partial with property like mode, which type is enum flag.
By default it will produce default SPA.
SSG of certain pages:

ssr({
   mode: RenderMode.SPA | RenderMode.SSG
}),

Prerender (SSG) all pages. Omit server directory (place it to fs.mkdtemp or os.tmpdir or even node_modules/.vite/ while prerendering)

ssr({
   mode: RenderMode.SSG
}),

Preserve SPA pages, prerender SSG pages, produce SSR build for SSR pages and corresponding server runtime.

ssr({
   mode: RenderMode.SPA | RenderMode.SSG | RenderMode.SSR
}),

Manual build script

ssr({
   mode: RenderMode.Manual
}),

For consistency, introduce setting for every case, something like:

ssr({
   // mode: ...
   client: {
      defaultSSRPage?: String, // page with hydration script, default: `renderer/_default.page.client.tsx`,
      defaultSPAPage?: String, // page with render script, default: `renderer/_default.page.client.tsx`
      html?: 'vite' (vite HTML middleware) | String (path to html file) ,
      clientOutputDir: String, // default is `${outDir}/client`,
      filter?: ({ pageContext, filename, ... }) => pageContext.exports['SPA'] === true,
   },
   server: {
      defaultScript?: String, // needed for generating hydratable HTML, default: `renderer/_default.page.server.tsx`
      serverOutputDir?: String, // default is `${outDir}/server`
      filter: ({ pageContext, filename, ... }) => pageContext.exports['SSR'] === true
   },
   prerender: {
      defaultScript?: String, // needed for generating non-hydratable HTML, default: `renderer/_default.page.server.tsx`,
      noExtraDir: Boolean,
      filter?: ({ pageContext, filename, ... }) => pageContext.exports['SSG'] === true
   },
})

I believe this flexible approach will make it clear how to use this plugin without looking for examples and why it's better than alternative solutions.

@MrFoxPro MrFoxPro added the enhancement 🚀 New feature or request label Dec 6, 2022
@MrFoxPro MrFoxPro changed the title Advanced configuration Convenient configuration Dec 6, 2022
@samuelstroschein
Copy link
Contributor

I think this overlaps with #53 (comment)

@MrFoxPro
Copy link
Author

MrFoxPro commented Dec 6, 2022

I think this overlaps with #53 (comment)

I see now, Yes. This could be better then defining all in configuration

@MrFoxPro MrFoxPro closed this as completed Dec 6, 2022
@brillout
Copy link
Member

brillout commented Dec 9, 2022

I agree the DX of configuring render modes can be improved. It's on the radar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants