vbenjs / vite-plugin-svg-icons

Vite Plugin for fast creating SVG sprites.
MIT License
819 stars 111 forks source link

run failed in cjs #25

Closed JobinJia closed 2 years ago

JobinJia commented 2 years ago

// in build.js

const svgIconsPlugin = require('vite-plugin-svg-icons')
const config = defineConfig({
  plugins: [
     vue(),
     vueJsx(),
     configSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        svgoOptions: true,
        // default
        symbolId: 'icon-[dir]-[name]',
     })
  ],
})
iainsimmons commented 2 years ago

Try one of these:

const { default: svgIconsPlugin } = require('vite-plugin-svg-icons')
const svgIconsPlugin = require('vite-plugin-svg-icons').default