Closed Mt-Youya closed 6 months ago
具体错误呢?
404 还要什么错误? GET https://cdnjs.cloudflare.com/ajax/libs/xlsx@0.18.5/dist/xlsx.full.min.js net::ERR_ABORTED 404 (Not Found) GET https://cdnjs.cloudflare.com/ajax/libs/axios@1.5.1/dist/axios.min.js net::ERR_ABORTED 404 (Not Found)
✅ https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.2/axios.min.js ❌ https://cdnjs.cloudflare.com/ajax/libs/axios@1.5.1/dist/axios.min.js
看起来像是解析出的URL不对。有尝试使用过resolve
和transform
选项吗?
看起来像是解析出的URL不对。有尝试使用过
resolve
和transform
选项吗?
没有,我去试试
看不懂 resolve 和transform 怎么用
transform
是一个钩子可以拿到最后转换的结果然后你访问script节点修改节点对应的url就行
你如果不会配置可以升级到1.0.0
版本这是一个稳定版本同时废弃了transform和url 采用resolve的方式 就行。
import { cdnjs } from 'vite-plugin-cdn2/resolver/cdnjs'
import { cdn } from 'vite-plugin-cdn2'
cdn({
modules:[],
resolve: cdnjs()
})
npm run build
pnpm build
都会报错 :
vite-plugin-cdn2: react-dom try resolve file failed.
vite-plugin-cdn2: react try resolve file failed.
okay了