Socket
Socket
Sign inDemoInstall

generator-web-component

Package Overview
Dependencies
170
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    generator-web-component

Quickly scaffold web components with Yeoman


Version published
Weekly downloads
11
Maintainers
1
Install size
15.0 MB
Created
Weekly downloads
 

Changelog

Source

v2.1.0 (2018-02-26)

Full Changelog

Readme

Source

Web Component Generator NPM version

Quickly scaffold lightweight web components with Yeoman, with just what's needed and none of the cruft. Built against the v1 Web Components spec.

Contents

Features

  • Generate standalone projects for distribution, or single file elements inside your own apps
  • Choose whether to bundle a framework like Polymer or build barebones
  • Optionally include Shadow DOM template boilerplate
  • Standalone projects come with a basic testing setup via Web Component Tester and a beautiful demo page served with browsersync

Check out the files in app/templates in this repo for a better idea of what you'll get.

Installation & usage

Install Yeoman and the component generator with NPM or Yarn

$ npm i -g yo generator-web-component

Then run it

$ yo web-component

Components for apps

To create a new web component for use inside an existing project, select 'Part of an app' when prompted. This will generate a single HTML file under the name of your element with the bare minimum of boilerplate.

Standalone components

To create a standalone element project in its own repo, select 'Standalone' when prompted. This will scaffold out a modern Web Component project, including a lightweight testing setup, a beautiful demo page, and standard config files.

It's recommended to build your element as an ES6 class directly in the [element-name].html file provided (or change it to a JavaScript file if you like), and allow the consumers of your element to do their own transpilation to ES5 if they want to support legacy browsers.

The following NPM scripts will be configured for you:

ScriptDescription
testRuns your WCT test suite in local browsers
posttestRuns Eslint after tests (eg: for Travis)
demoRuns a demo server (with Browsersync) which reloads whenever you make changes in your component

Run the scripts with NPM

$ npm run demo

The demo server is available on localhost:3000


Todo

There are a few more options that should be added to this generator, if you'd like to contribute a PR adding any of these features I'll gladly merge it!

  • Add optional (and configurable) buildstep (issue)
    • Rollup module bundling
    • PostCSS + Autoprefixer
  • Add SkateJS framework option (issue)
  • Bundle Yeoman and Browsersync into web-component-cli? In similar vein to polymer-cli but not tied to a framework

MIT © Sean King

Keywords

FAQs

Last updated on 26 Feb 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc