From a1e4d15d1ea8d9ef2cf78f14b2e3a1f247270c6f Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 17 Nov 2020 14:36:09 +0100 Subject: [PATCH] Don't hardcode the package name when looking up assets The rollup json plugin allows accessing keyss with named exports, so we can read the package name at build time. --- packages/common/src/icon.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/common/src/icon.js b/packages/common/src/icon.js index beec4968..a0d22df7 100644 --- a/packages/common/src/icon.js +++ b/packages/common/src/icon.js @@ -2,6 +2,7 @@ import {html, LitElement, css} from 'lit-element'; import {unsafeHTML} from 'lit-html/directives/unsafe-html.js'; import {until} from 'lit-html/directives/until.js'; import * as commonUtils from '../utils.js'; +import {name as pkgName} from './../package.json'; // Use in case the icon fails to load const errorIcon = ` @@ -18,7 +19,7 @@ const errorIcon = ` `; export function getIconSVGURL(name) { - return commonUtils.getAssetURL('dbp-common', 'icons/' + encodeURI(name) + '.svg'); + return commonUtils.getAssetURL(pkgName, 'icons/' + encodeURI(name) + '.svg'); } export function getIconCSS(name) { -- GitLab