emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
116 stars 15 forks source link

Support EJS Extension #73

Closed chmmpagne closed 2 months ago

chmmpagne commented 2 months ago

For better IDE completion and correctness, it would be nice to be able to name the template file with a .ejs extension. I.e., index.ejs.

I believe this would just be a change to the types (TplStr) to allow this as well as some documentation updates.

export type AllowedExtensions = 'ejs' | 'html';
export type TplStr<T extends string> = T extends `/${infer P}`
  ? TplStr<P>
  : T extends `${infer Q}.${AllowedExtensions}`
    ? TplStr<Q>
    : `${T}.${AllowedExtensions}`;

It may be even better to not restrict the file extension at all.

emosheeep commented 2 months ago

Does it work well without any other logic changes?

chmmpagne commented 2 months ago

Does it work well without any other logic changes?

I haven't done any real testing, but it looked to me like these paths weren't getting any additional attention that would need more changes.

chmmpagne commented 2 months ago

The PR needs to be updated to only allow .html for filenames; .ejs and .html for templates. No logic changes needed from my testing.

Edit: Updated PR.