🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

elm-app-webcomponent

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elm-app-webcomponent

### Installation

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Build web-component using create-elm-app

Installation

  • add this plugin as a development dependency of a project you created with create-elm-app
yarn add -D elm-app-webcomponent
  • use plugin in elmapp.config.js
exports.configureWebpack = require('elm-app-webcomponent');

Usage

  • You need to create an entry point for your web component in src/custom-element.js, this is a boilerplate you might want to start with:
const Elm = require('./Main');
const css = require('./main.css').toString();

customElements.define('my-webcomponent',
    class extends HTMLElement {

        constructor() {
            super();

            const appRoot = document.createElement('div');
            const appStyles = document.createElement('style');
            appStyles.textContent = css;

            const shadowRoot = this.attachShadow({mode: 'open'});
            shadowRoot.appendChild(appStyles);
            shadowRoot.appendChild(appRoot);
            this.appRoot = appRoot;
        }

        connectedCallback() {
            const app = Elm.Elm.Main.init({ node: this.appRoot });
            this.app = app;
        }
});
  • Run elm-app build as usual to build your web component.

FAQs

Package last updated on 28 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts