# elm-app-webcomponent

> ### Installation

Latest version **1.0.0** (published 2018-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install elm-app-webcomponent
pnpm add elm-app-webcomponent
yarn add elm-app-webcomponent
bun add elm-app-webcomponent
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-12-28 |
| First published | 2018-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | anatoliy |

## Links

- npm: https://www.npmjs.com/package/elm-app-webcomponent
- npm.io page: https://npm.io/package/elm-app-webcomponent

## Dependencies (1)

- [to-string-loader](https://npm.io/package/to-string-loader.md) ^1.1.5

## Recent versions

- 1.0.0 (latest) — 2018-12-28

## README

## Build web-component using create-elm-app

### Installation

1. add this plugin as a development dependency of a project you created with `create-elm-app`

```
yarn add -D elm-app-webcomponent
```

2. use plugin in `elmapp.config.js`

```javascript
exports.configureWebpack = require('elm-app-webcomponent');
```

### Usage

1. 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:


```javascript
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;
        }
});
```

2. Run `elm-app build` as usual to build your web component.

---
_Source: https://npm.io/package/elm-app-webcomponent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
