位置: IT常识 - 正文
推荐整理分享Vue3 + Vite 多入口配置(vue多入口文件),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:vue项目配置多入口,vue多入口配置,vue项目的入口,vue多入口优点,vue3 addroute,vue3 addroute,vue3 addroute,vue多入口跳转,内容如对您有帮助,希望把文章链接给更多的朋友!
试了一下多入口跳转的问题:
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引用的类似报错也按照这么处理即可
上一篇:赤狐,荷兰 (© Wim Weenink/Minden Pictures)
下一篇:前端加密,后端解密的过程及代码(密码明文传输解决,不是太保险。key在前端有显示)(前端加密后端解密代码)
友情链接: 武汉网站建设