vbenjs / vite-plugin-html

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

Bug: Unable find target HTML to render #114

Open NWYLZW opened 1 year ago

NWYLZW commented 1 year ago

RT

HTML path include vite config base which will unable find target HTML page, because path.realative will compute error

telegram-cloud-photo-size-5-6143281823472530627-y telegram-cloud-photo-size-5-6143281823472530629-y

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

xiaohuohumax commented 10 months ago

me too v3.2.1

project path uri:

d:/...../project-name/...........

vite.config.ts:

{
    envDir,
    base: "/project-name",
    plugins: [
        ...,
        createHtmlPlugin({
            pages: [
                {
                    entry: 'src/main.ts',
                    filename: 'index.html',
                    template: 'index.html',
                    injectOptions: {
                        data: {
                            title: "..."
                        }
                    }
                }
            ]
        })
    ],
}

error

 ERROR  [vite:build-html] ejs:8                                                                                               23:12:13  
    6|   <link rel="icon" type="image/svg+xml" href="/logo.png" />
    7|   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 >> 8|   <title><%- title %></title>
    9|   <style>
    10|     :root {
    11|       --app-context-color: #67bc66;

title is not defined

v3.0.6 is ok!