Vite.js 不在多页应用程序中发出 HTML 文件
Vite.js not emitting HTML files in multi page app
我有一个多页面应用程序,我正在尝试使用 Vite.js
构建(从 Webpack
迁移)。在构建 Vite + React 示例代码时,我看到它发出:
dist/index.html
dist/assets/<various assets>
但是,当我尝试制作如图所示的多页应用程序时,in the docs 会发出 none 的 HTML(但 /assets/
的其余内容在那里)。这是为什么?
// vite.config.js excerpt:
import { defineConfig } from 'vite'
import { dirname } from 'path';
import { fileURLToPath } from 'url';
export default defineConfig({
root: 'client',
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: dirname(fileURLToPath(import.meta.url + 'index.html')),
login: dirname(fileURLToPath(import.meta.url + 'login.html')),
}
}
},
});
尝试使用 URL
作为 vite doc
中指定的文件输入
main: new URL('./client/index.html', import.meta.url).pathname
我有一个多页面应用程序,我正在尝试使用 Vite.js
构建(从 Webpack
迁移)。在构建 Vite + React 示例代码时,我看到它发出:
dist/index.html
dist/assets/<various assets>
但是,当我尝试制作如图所示的多页应用程序时,in the docs 会发出 none 的 HTML(但 /assets/
的其余内容在那里)。这是为什么?
// vite.config.js excerpt:
import { defineConfig } from 'vite'
import { dirname } from 'path';
import { fileURLToPath } from 'url';
export default defineConfig({
root: 'client',
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: dirname(fileURLToPath(import.meta.url + 'index.html')),
login: dirname(fileURLToPath(import.meta.url + 'login.html')),
}
}
},
});
尝试使用 URL
作为 vite doc
main: new URL('./client/index.html', import.meta.url).pathname