• 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引用的类似报错也按照这么处理即可

  • 相关阅读:
    Linux创建与删除用户
    SpringBoot系列(二)指定内置tomcat版本
    C语言求该二维数组的最大值
    Redis--内存回收机制详解
    Numpy入门[16]——choose函数实现条件筛选
    【SQL】MySQL中的约束
    致敬最美逆行者网页设计作品 大学生抗疫感动专题网页设计作业模板 疫情感动人物静态HTML网页模板下载
    【Redis】保证redis的高并发高可用的几种策略
    哈希算法(一)Java实现常用的哈希算法
    Go 语言错误处理方式
  • 原文地址:https://blog.csdn.net/u010994219/article/details/126701673