vbenjs / vite-plugin-html

A vite plugin for processing html. It is developed based on lodash template
MIT License
604 stars 96 forks source link

Not working when using other directory for html's #118

Open kiyoshi-satoo opened 1 year ago

kiyoshi-satoo commented 1 year ago

This is project simple strcuture

image

 plugins: [
      createHtmlPlugin({
        pages: [
          {
            filename: "index.html",
            template: "src/templates/index.html",
            injectOptions: {
              data: {
                title: "index",
                injectScript: `<script src="./inject.js"></script>`,
              },
              tags: [
                {
                  injectTo: "body-prepend",
                  tag: "div",
                  attrs: {
                    id: "tag1",
                  },
                },
              ],
            },
          },
        ],
      }),
    ],
  };

Looks like the project is no longer maintained.

ThornWalli commented 1 year ago

Hello @kiyoshi-satoo ,

you have to put something in the property here. build.rollupOptions.input

https://github.com/vbenjs/vite-plugin-html/blob/841d4ef04c3cf5ff0d4339350ae336aa83aa70ed/packages/core/src/htmlPlugin.ts#L248-L251

Otherwise ignore the case.

Unfortunately, the topic is a bit bigger, I once created a PR for the topic.

https://github.com/vbenjs/vite-plugin-html/pull/127