gpt4 book ai didi

javascript - Vite.js 不在多页应用程序中发出 HTML 文件

转载 作者:行者123 更新时间:2023-12-04 17:15:21 25 4
gpt4 key购买 nike

我有一个多页面应用程序,我正在尝试使用 Vite.js 构建它(从 Webpack 迁移)。在构建 Vite + React 示例代码时,我看到它发出:

  • dist/index.html
  • dist/assets/<various assets>

  • 但是,当我尝试制作如图所示的多页应用程序时 in the docs没有任何 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

    关于javascript - Vite.js 不在多页应用程序中发出 HTML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68794861/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com