Built in support for template engines
See original GitHub issueIs your feature request related to a problem? Please describe.
Yes. Trying to use anything but html
for your markup doesn’t quite work at the moment.
I’ve been trying to develop a Pug plugin and I got stuck.
There were a few tickets (#842 #528 #17 ) closed, but I don’t think the issue is solved.
By making a plugin using transformIndexHtml you would still need an index.html
. You can’t have a structure like this for example:
_main.pug
index.pug << extends _main.pug
about/
|-- index.pug << extends _main.pug
vite.config.js
Snowpack had a similar issue where the transformed files were not routed and they were able to fix it, any chance we could get some ideas from it?
Describe the solution you’d like
Being able to use template engines like handlebars
, mustache
or pug
by just installing a plugin package or the engine package.
Describe alternatives you’ve considered Couldn’t really find a solution to this.
Additional context
I also made a demo repo if that helps.
Unfortunately templating seems to be something left behind by most tools. If all you wanna do is make a website that is mostly HTML and CSS you shouldn’t need a huge JS bundle.
I would love to help make this happen, if anyone can point me in the right direction that would be much appreciated.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (9 by maintainers)
Top GitHub Comments
@yyx990803 The use case is the same as vitepress and other SSGs. It’s a way to generate fast and SEO-proof website with multiple pages that have their rather complex scripts built with vite.
I fell in love with
pug
andstylus
while working with SFCs in vite. But then I want to have just a couple of pages around my base app page? Think aboutabout us
andpricing
pages. For now we can write them only with plain html and manually add to the multi-page list on the Rollup config. But imagine if we had an option to have a whole structure of templates with rather complex apps built just for each page. May be it’s too much for one tool? 🤷♂️I’ve played around with the
transformIndexHtml()
and could makepug
templates somehow working, but finally moved to11ty.js
to make this work and use vite to build just the libs that will be manually included into those pages as scripts. So every tool does it’s own job ) But may be once there will be that universal tool for vue 3. May be new Nuxt will do that?https://github.com/alexlafroscia/vite-plugin-handlebars/issues/39#issuecomment-817306337 something similiar was discussed here couple of days ago, regarding different extention then .html
Agree that built-in support is not really what is needed, but better support so this can be done with plugins is. Template engine plugins could be then added here https://github.com/vitejs/awesome-vite#plugins 🙂