首页IT科技vue的入口文件是什么(Vue3 + Vite 多入口配置)

vue的入口文件是什么(Vue3 + Vite 多入口配置)

时间2025-05-24 16:15:41分类IT科技浏览3818
导读:试了一下多入口跳转的问题: import {defineConfig}...

试了一下多入口跳转的问题:

import {defineConfig} from "vite"; import vue from "@vitejs/plugin-vue"; import path from "path"; import styleImport, {VantResolve} from "vite-plugin-style-import"; // https://vitejs.dev/config/ export default defineConfig({ server: { open: true, port: 3005, host: "0.0.0.0", }, resolve: { alias: { "@": path.resolve(__dirname, "src"), }, }, build: { emptyOutDir: true, rollupOptions: { input: { entry: path.resolve(__dirname, index.html), privacy: path.resolve(__dirname, privacy.html), terms: path.resolve(__dirname, terms.html), refund: path.resolve(__dirname, refund.html), about: path.resolve(__dirname, about.html), } } }, plugins: [ vue(), styleImport({ resolves: [VantResolve()], }), ], });

其实就是多了个build

empty就是“是否清空输出目录”,默认也是true。

然后就会出现这样的报错:

[vite]: Rollup failed to resolve import "src/main.js" from "index.html".

This is most likely unintended because it can break your application at runtime.

If you do want to externalize this module explicitly add it to

`build.rollupOptions.external`

error during build:

Error: [vite]: Rollup failed to resolve import "src/main.js" from "index.html".

This is most likely unintended because it can break your application at runtime.

npm ERR! land-page@0.0.0 build_local: `vite build`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the land-page@0.0.0 build_local 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\admin\AppData\Roaming\npm-cache\_logs\2022-09-05T03_36_40_610Z-debug.log

  <script type="module" src="src/main.js"></script> 改成 <script type="module" src="./src/main.js"></script>

style引用的类似报错也按照这么处理即可

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
seo优化的技巧(seo关键字优化方案)