DEV Community

Jeremy Jackson
Jeremy Jackson

Posted on

1 1

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)

SurveyJS custom survey software

JavaScript UI Library for Surveys and Forms

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

View demo

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay