how to use cdn with vite(using react + antd-mobile)?

Viewed 889

browser reports error:

Uncaught TypeError: Failed to resolve module specifier "antd-mobile". Relative references must start with either "/", "./", or "../".

my config:

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'],
    }
  }
})

0 Answers
Related