DEV Community

loading...

SVGs with MithrilJS and Webpack

Jeremy Jackson
・1 min read

Add the following to webpack.config.js

module: {
  rules: [{
    test: /\.svg/,
    type: 'asset/source'
  }]
}
Enter fullscreen mode Exit fullscreen mode

Import your SVG into your component

import svgIcon from './svgs/mySvgIcon.svg';
Enter fullscreen mode Exit fullscreen mode

Use m.trust to render it.

m.trust(svgIcon)
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

Forem Open with the Forem app