0

Polymer treats relative URLs as relative to main document. Polymer 3 provides a [[importPath]] value for relative URLs. LitElement does not provide this helper. What is the best way to handle relative paths in LitElement using Polymer CLI build process ?

MadeInLagny
  • 185
  • 1
  • 12

1 Answers1

0

Polymer needed [[importPath]] due to using HTML imports.

Lit uses ES6 modules, so you can get the current path with import.meta.url.

As there is a built in browser mechanism to access the URL Lit doesn't provide its own (which is core design principle of Lit), but there is a way to shim it - throw and catch an Error and the stack property will include the current file. I don't recommend it though as the browser versions that support modules but not import.meta are extremely obscure.

Keith
  • 150,284
  • 78
  • 298
  • 434