typescript - איך להשתמש ב-CDN עם Vite (בעבודה עם React + antd-mobile)?
דפדפן מדווח על שגיאה:
שגיאת TypeError לא נתפסה: נכשלה פתירת המזהה של המודול "antd-mobile". הפניות יחסיות חייבות להתחיל באחד מהבאים: "/", "./", או "../".
הקונפיגורציה שלי:
import reactRefresh from '@vitejs/plugin-react-refresh'
import {defineConfig} from 'vite'
import cdn from 'vite-plugin-cdn'
// https://vitejs.dev/config/
export default defineConfig({
base: '',
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
}
}
},
plugins: [
reactRefresh(),
cdn({
modules: [
{
name: 'antd-mobile',
url: 'https://cdnjs.cloudflare.com/ajax/libs/antd-mobile/2.3.4/antd-mobile.min.js'
}
]
})
],
build: {
rollupOptions: {
external: ['antd-mobile'],
}
}
})