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

Is this repo actively maintained? #112

Open
ehossack opened this issue Mar 5, 2023 · 5 comments
Open

Is this repo actively maintained? #112

ehossack opened this issue Mar 5, 2023 · 5 comments

Comments

@ehossack
Copy link

ehossack commented Mar 5, 2023

Normally I hate such issues being filed, but they are also a good indicator as to the health of a repo, if someone is considering using a library.

In this case, I've recently tried emailing the maintainer(s) and gotten no response, as well as observed a bunch of stale issues.

Does the maintainer need help? Should this repo be forked?

@ehossack
Copy link
Author

ehossack commented Mar 5, 2023

For my own needs, I was able to replicate the functionality of this library using solely two widely-used libraries, ejs and html-minifier.

e.g. code below (typescript)

In plugins list:

...
plugins: [
	...,
	processHtml(true, templateVariables),
]

And then the code:

function processHtml(shouldMinify: boolean, templateVariables: MyProjectEjsTemplateVariables): PluginOption {
  return {
    name: 'myproject:processHtml',
    enforce: 'pre',
    transformIndexHtml: {
      enforce: 'pre',
      transform(html: string) {
        const rendered = ejs.render(html, { ...templateVariables }, { root: __dirname });
        return shouldMinify
          ? minify(
              rendered,
              // https://github.com/kangax/html-minifier#options-quick-reference
              {
                collapseWhitespace: true,
                removeComments: true,
                removeAttributeQuotes: true,
                removeScriptTypeAttributes: true,
                removeRedundantAttributes: true,
                removeTagWhitespace: true,
              }
            )
          : rendered;
      },
    },
  };
}

@filipw01
Copy link

If you only need ejs there is this plugin https://github.com/trapcodeio/vite-plugin-ejs

@rdhelms
Copy link

rdhelms commented Mar 22, 2023

I'd also love to get an answer to this - we're looking to migrate to Vue 3 and I was under the impression that this package was the standard migration path for projects that used ejs in the entry index.html.

It certainly wasn't obvious from the Vue 3 docs though, so it would be helpful to know if that's an incorrect assumption.

@tnrich
Copy link

tnrich commented Jun 27, 2023

I've found vite-plugin-virtual-html to be a much easier to use plugin!

Here's how I'm using it and it is awesome!

plugins: [vitePluginVirtualHtml({
       pages: {
        index: {
          entry: './demo/index.js', // MUST
          title: `${name} demo`,// optional, default: ''
          body: '<div id="app"><div id="demo"></div></div>' // optional, default: '<div id="app"></div>'
        }
       },
    })]

@wojtekmaj
Copy link

I also created an alternative.

vite-plugin-simple-html.

Supports:

  • EJS variables
  • Tag injection
  • HTML, CSS and JS minification

I built that to cover my needs in a large project I maintain so rest assured, it won't be abandoned anytime soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants