typescript - 如何将 cdn 与 vite 一起使用(使用 react + antd-mobile)?
问题描述
浏览器报错:
未捕获的类型错误:无法解析模块说明符“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'],
}
}
})
解决方案
推荐阅读
- swift - Swift为什么退格的strcmp返回-92?
- javascript - 在 Web 应用程序中打开 excel 文件
- ios - 在 Objective C 中的 UIView 中的命中测试
- r - dcast 并聚合到 r 中的长度
- mysql - 检查一行中的不同值 - sql
- dart - 如何将图像从屏幕底部移动到屏幕顶部
- angular - 即使添加到入口组件后,也找不到 ngx-bootstrap 模态组件
- python - pickle 如何处理递归对象的序列化?
- javascript - RangeError,语法错误:无效的正则表达式
- rust - 如何为特征的每个实现自动生成递增的数字标识符?