I’m trying to import an svg in Vanilla ES6 / ES7 to use with mo.js like in this example https://mojs.github.io/tutorials/shape-swirl/#custom-shapes.
I’ve tried to put the code in a javascript module and import it without success because it gave an error in console:
Now I’m trying to import it using https://www.npmjs.com/package/svg-inline-loader.
let charIcon = require('../images/content/logo-char.svg');
console.log(charIcon);
class Char extends mojs.CustomShape {
getShape() { return charIcon; }
}
mojs.addShape('char', Char); // passing name and Bubble class
// now it is avaliable on mojs.Shape constructor as usual
const logoChar = new mojs.Shape({
parent: '#logoChar',
shape: 'char',
scale: { 0: 1 },
});
When I console log it doesn’t return the code of the svg but instead returns a base64:
How can I import the svg code from a javascript module like in the first in example or import the code from a svg file? I’d prefer the first method by importing a module in order to be able to see the code and change if needed.
Hope the issue is clear.
Thank you!