首页 前端知识 vite ant-design-vue upload-dragger打包报错 Rollup failed to resolve

vite ant-design-vue upload-dragger打包报错 Rollup failed to resolve

2024-05-13 10:05:36 前端知识 前端哥 456 63 我要收藏

文章目录

    • 问题
    • 临时规避
    • 正解

问题

[vite]: Rollup failed to resolve import "D:/VueProject/vben-admin-thin-next/node_modules/ant-design-vue/es/upload-dragger/style/index" from "src/views/neat/create/step1.vue".
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 "D:/VueProject/vben-admin-thin-next/node_modules/ant-design-vue/es/upload-dragger/style/index" from "src/views/neat/create/step1.vue".
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`
    at onRollupWarning (D:\VueProject\vben-admin-thin-next\node_modules\vite\dist\node\chunks\dep-c9998dc6.js:41797:19)
    at onwarn (D:\VueProject\vben-admin-thin-next\node_modules\vite\dist\node\chunks\dep-c9998dc6.js:41613:13)
    at Object.onwarn (D:\VueProject\vben-admin-thin-next\node_modules\rollup\dist\shared\rollup.js:23215:13)
    at ModuleLoader.handleResolveId (D:\VueProject\vben-admin-thin-next\node_modules\rollup\dist\shared\rollup.js:22465:26)
    at D:\VueProject\vben-admin-thin-next\node_modules\rollup\dist\shared\rollup.js:22426:26
error Command failed with exit code 1.

原因是antdv下面只有upload,没有upload-dragger,但是引入UploadDragger 却没有报错,打包的时候找不到。

import { UploadDragger } from 'ant-design-vue';

临时规避

https://blog.csdn.net/lianlin21212411/article/details/124615901 参考这个博主把upload复制一份改名之后可以正常打包了。

在这里插入图片描述

正解

其实,可以从upload引入dragger

import { Upload } from 'ant-design-vue';
const AUploadDragger = Upload.Dragger;


<a-upload-dragger....
转载请注明出处或者链接地址:https://www.qianduange.cn//article/8492.html
标签
评论
会员中心 联系我 留言建议 回顶部
复制成功!