• Vue3 + Vite 多入口配置


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

    1. import {defineConfig} from "vite";
    2. import vue from "@vitejs/plugin-vue";
    3. import path from "path";
    4. import styleImport, {VantResolve} from "vite-plugin-style-import";
    5. // https://vitejs.dev/config/
    6. export default defineConfig({
    7. server: {
    8. open: true,
    9. port: 3005,
    10. host: "0.0.0.0",
    11. },
    12. resolve: {
    13. alias: {
    14. "@": path.resolve(__dirname, "src"),
    15. },
    16. },
    17. build: {
    18. emptyOutDir: true,
    19. rollupOptions: {
    20. input: {
    21. entry: path.resolve(__dirname, 'index.html'),
    22. privacy: path.resolve(__dirname, 'privacy.html'),
    23. terms: path.resolve(__dirname, 'terms.html'),
    24. refund: path.resolve(__dirname, 'refund.html'),
    25. about: path.resolve(__dirname, 'about.html'),
    26. }
    27. }
    28. },
    29. plugins: [
    30. vue(),
    31. styleImport({
    32. resolves: [VantResolve()],
    33. }),
    34. ],
    35. });

    其实就是多了个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
     

    1. 改成

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

  • 相关阅读:
    插件_日期_lunar-calendar公历农历转换
    Redis6入门笔记。别急慢慢来
    计算机毕业设计node.js+Vue+Element电商后台管理系统
    Linux下的Swap内存
    window cmd/PowerShell 实时查看监控日志命令Get-Content,类似与linux shell的tail命令
    部署应用链太费心?Tanssi 教你轻松开发部署
    哈希加盐算法
    软件项目管理文档模板目录
    求一份网页设计结课大作业,要求用到html,css,javascript,的知识
    Llama改进之——分组查询注意力
  • 原文地址:https://blog.csdn.net/u010994219/article/details/126701673