1

I started an app with vite, and I'm having some trouble bundling it with rollup.

Running yarn rollup -c gives me the following error:

[!] RollupError: "default" is not exported by "src/assets/svg/basic_icons/Atom.svg", imported by "src/components/basic_icons/atom.tsx"

The atom.tsx component looks like this:

import svgUrl, { ReactComponent as Atom } from '../../assets/svg/basic_icons/Atom.svg'; 
export default svgUrl; 
export { Atom };

Atom.svg is just your usual SVG.

This is my rollup config:

import svgr from '@svgr/rollup';
import url from '@rollup/plugin-url'
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import external from 'rollup-plugin-peer-deps-external';
import typescript from '@rollup/plugin-typescript';
import svg from 'rollup-plugin-svg';


export default {
    input: 'src/index.ts',
    output: [
        {
            file: 'build/bundle.js',
            format: 'cjs',
            sourcemap: true,
            name: 'icons'
        },
    ],
    plugins: [
        url({
            include: ['**/**.svg']
        }), 
        svg({
            output: 'module',
            defaultExport: 'svgUrl'
        }),
        svgr({ babel: false, jsx: { namedExports: true } }),
        resolve(),
        commonjs(),
        typescript({ tsconfig: './tsconfig.json' }),
        external(),
        terser()
    ],
}
hmrbcnt
  • 93
  • 6

0 Answers0