将来自 CDN 的导入包含到 Rollup 的捆绑包中

问题描述 投票:0回答:1

如何使用 Rollup 将外部依赖项导入到我的包中?

通过下面的示例,我想将 lit-html 包含到我的包中。

import { html, render } from 'https://cdn.skypack.dev/lit-html';
class extends HTMLElement {
    constructor() {
      super();
      this.attachShadow({ mode: 'open' });
      this.render();
    }
    render() {
      render(this.template, this.shadowRoot, { eventContext: this });
    }    
    get template() {
      return html`<h1>Hello, world</h1>`;
    }
}

javascript rollup rollupjs
1个回答
-1
投票

不确定您是否已经得到答案,但您可以尝试这个插件:https://github.com/mjackson/rollup-plugin-url-resolve

© www.soinside.com 2019 - 2024. All rights reserved.