Vite packaging error: Error: [vite]: Rollup failed to resolve import “***/style/index” from “***“

vite packaging error

Error: [vite]: Rollup failed to resolve import "D:/demo/node_modules/ant-design-vue/es/time-range-picker/style/index" from "src/views/coupon/components/UseTime/index.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`

The reason for the error may be that the time-range-picker component is not directly exported in ant, but I used it directly in the page.

Use import { TimeRangePicker} from 'ant-design-vue'; to write in this way, running directly locally will not report an error, but it will report an error when yarn build is packaged.

Solution: Modify the import wording as

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

components: {
    
     TimeRangePicker: TimePicker.TimeRangePicker}
<TimeRangePicker> 
<TimePicker.TimeRangePicker> 

Again the packaging issue was resolved.

Guess you like

Origin blog.csdn.net/Heixiu6/article/details/128441768