使用多页构建不适用于 vite 2.6 和 vue 3.2

build with multi page don't work with vite 2.6 and vue 3.2

我用 vue 3.2 和 vite 2.6 做了一个简单的多页面应用程序

|-src
|---main.js
|-package.json
|-vite.config.js
|-index.html
|-validation_password.html

但是当我想要构建它时:vite 只构建索引页面(而不是验证密码)。 我尝试使用 here :

之类的汇总选项修改我的 vite.config.js
const { resolve } = require('path')

module.exports = defineConfig({
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        valpass: resolve(__dirname, 'validation_password.html')
      }
    }
  }
})

构建失败。我的终端出现这个错误:

[rollup-plugin-dynamic-import-variables] Unexpected token (1:0)
file: C:/wamp64/www/IMB/VueJS/vuejs/src/PassVal.vue:1:0
error during build:
SyntaxError: Unexpected token (1:0)
    at Parser.pp.raise (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:19495:13)
    at Parser.pp.unexpected (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:16820:8)
    at Parser.pp.parseExprAtom (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18870:10)
    at Parser.pp.parseExprSubscripts (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18662:19)
    at Parser.pp.parseMaybeUnary (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18628:17)
    at Parser.pp.parseExprOps (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18561:19)
    at Parser.pp.parseMaybeConditional (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18544:19)
    at Parser.pp.parseMaybeAssign (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18512:19)
    at Parser.pp.parseExpression (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:18476:19)
    at Parser.pp.parseStatement (C:\wamp64\www\IMB\VueJS\vuejs\node_modules\rollup\dist\shared\rollup.js:17010:45)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! components-portail-math@0.0.1 build: `vite build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the components-portail-math@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\willb\AppData\Roaming\npm-cache\_logs21-10-07T14_34_53_913Z-debug.log

我的 PassVal.vue 文件在本地损坏不用担心。 我不明白。我正在关注文档。

我用Vue Router(我不知道)解决了我的问题。