1

I am using svg.js alongside svg.draggable.js in a Angular 7 application built using Angular-cli. Locally everything is working fine but once i do a production build I get the error .draggable is not a function when accesing the page.

Here's how I use both of them in my component:

import * as SvgJs from '@svgdotjs/svg.js';
import '@svgdotjs/svg.draggable.js';

It's like if for the production build Angular-cli is not including svg.draggable.

Maybe I need to do something more but as it's working locally I don't really know what. Does anyone knows why it happens and how to solve this?

Maybe it's not related to svg.draggable.js specifically but to Angular-cli by the way but I have no clue.

Maxime
  • 235
  • 1
  • 2
  • 12

2 Answers2

0

package.json

"@svgdotjs/svg.draggable.js": "^3.0.2",
"@svgdotjs/svg.filter.js": "3.0.6",
"@svgdotjs/svg.js": "3.0.12",
"@svgdotjs/svg.panzoom.js": "^2.0.3",

...
"devDependencies": {
  "@angular-devkit/build-angular": "0.800.1",   //not 0.800.2 !!!
"@angular/cli": "8.0.1",
...

component

import { SVG, G, Pattern, Text, TextPath, Image, Svg } from '@svgdotjs/svg.js'
import '@svgdotjs/svg.filter.js'
import '@svgdotjs/svg.panzoom.js'
import '@svgdotjs/svg.draggable.js'

....
  const imageSVG = this.draw.image(dataUrl).draggable() 
....  

node_modules

svj.js master from 24.05.2019  !!!!!

https://citysoft.pl/przypinam/dashboard

PiotrF
  • 73
  • 5
0

My issue came from the fact that I was using a branch of my fork, so not the compiled version of it. I published my fork over to a private npm and it worked. Now with the new tag it works even with the official package.

So my bad on this one.

Maxime
  • 235
  • 1
  • 2
  • 12