DEV Community

Jeremy Jackson
Jeremy Jackson

Posted on

SVGs with MithrilJS and Webpack

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

Top comments (0)