I wanted to display a custom SVG for the google maps marker. To get the raw SVG you can do the following.

1
npm install raw-loader

Use the raw-loader for a single import by adding !raw-loader! in front. In this example we color a font-awesome icon.

1
2
3
import truckSVG from '!raw-loader!@/assets/truck-duotone.svg';
let purpleSVG = truckSVG.replace(/currentColor/g, 'purple');
img.src = 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(purpleSVG);

@/ is a path alias in webpack that points to /src/

Alternatives are, using the html-loader or svg-inline-loader