文章目录
- 问题
- 临时规避
- 正解
问题
[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....