This is about compiling
dom-to-svg, but it probably applies to most libraries that are set up for a webpack build process.
- create
./src
and ./dist
dirs
- create index.html in
dist
- install libraries
npm install --save dom-to-svg
etc.
- set up package.json like here https://webpack.js.org/guides/getting-started/
- create src/index.js and refer to the libraries in it
import { documentToSVG, elementToSVG, inlineResources, formatXML } from 'dom-to-svg'
- run webpack
npx webpack
a minimal
index.js
is as follows:
import { documentToSVG, elementToSVG, inlineResources, formatXML } from 'dom-to-svg'
window.domToSVG = {}
domToSVG.documentToSVG = documentToSVG
domToSVG.elementToSVG = elementToSVG
domToSVG.inlineResources = inlineResources
domToSVG.formatXML = formatXML