vite-plugin-html
vite-plugin-html copied to clipboard
本地开发多页面配置,生成的 index.html 和 other.html 都是基于 index.html 模板,other.html 模板没生效
本地开发多页面配置,生成的 index.html 和 other.html 都是基于 index.html 模板,other.html 模板没生效,想问一下如何能让 other.html 模板生效?
如下代码:
import { defineConfig } from 'vite'
import { createHtmlPlugin } from 'vite-plugin-html'
export default defineConfig({
plugins: [
createHtmlPlugin({
minify: true,
pages: [
{
entry: 'src/main.ts',
filename: 'index.html',
template: 'public/index.html',
injectOptions: {
data: {
title: 'index',
},
},
},
{
entry: 'src/other-main.ts',
filename: 'other.html',
template: 'public/other.html',
injectOptions: {
data: {
title: 'other page',
},
},
},
],
}),
],
})
me too
me too
要访问全路径
要访问全路径
还是要看源码啊。那确切的说应该是template要和filename一致,并指向文件真实路径
同问,我也想这样操作,但没能成功
最近也在搞这个问题,这样就不优雅了。配置需要template要和filename一致,并指向文件真实路径。关键是不放在root下面,带文件夹的话,比如 /src/entry, 那么访问路径也得加这个,那么配置的意义又在哪里