All Projects → IBM → pwa-lit-template

IBM / pwa-lit-template

Licence: MIT license
A template for building Progressive Web Applications using Lit and Vaadin Router.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pwa-lit-template

bui
‹b› Web components for creating applications – built by Blackstone Publishing using lit-html and lit-element
Stars: ✭ 29 (-81.76%)
Mutual labels:  web-components, lit, lit-html, lit-element
pharos
JSTOR's design system
Stars: ✭ 48 (-69.81%)
Mutual labels:  web-components, lit, lit-html, lit-element
lit-components
Moved to https://github.com/vaadin/component-mixins
Stars: ✭ 59 (-62.89%)
Mutual labels:  web-components, lit-html, lit-element
hello-web-components
A simple starter <hello-world /> web component written in typescript, using lit-html and lit-element. Unit tested with jest and e2e tested with puppeteer and jest-puppeteer.
Stars: ✭ 15 (-90.57%)
Mutual labels:  web-components, lit-html, lit-element
lit
Lit is a simple library for building fast, lightweight web components.
Stars: ✭ 12,406 (+7702.52%)
Mutual labels:  lit, lit-html, lit-element
rollup-plugin-lit-css
Moved to https://github.com/bennypowers/lit-css
Stars: ✭ 35 (-77.99%)
Mutual labels:  lit, lit-html, lit-element
Wired Elements
Collection of custom elements that appear hand drawn. Great for wireframes or a fun look.
Stars: ✭ 8,848 (+5464.78%)
Mutual labels:  web-components, lit-html, lit-element
pattern-library
AXA CH UI component library. Please share, comment, create issues and work with us!
Stars: ✭ 103 (-35.22%)
Mutual labels:  lit-html, lit-element
eslint-plugin-lit
lit-html support for ESLint
Stars: ✭ 90 (-43.4%)
Mutual labels:  web-components, lit
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (-81.13%)
Mutual labels:  lit-html, lit-element
byu-theme-components
Web Components implementing the BYU web theme.
Stars: ✭ 21 (-86.79%)
Mutual labels:  web-components, lit-element
outline
Outline is a web component based design system starter kit. Outline is based on the latest technologies and tools to help your component authoring experience and facilitate adoption in your organization.
Stars: ✭ 28 (-82.39%)
Mutual labels:  web-components, lit
wc-context
Context for Web Components
Stars: ✭ 26 (-83.65%)
Mutual labels:  web-components, lit-element
Haunted
React's Hooks API implemented for web components 👻
Stars: ✭ 2,197 (+1281.76%)
Mutual labels:  web-components, lit-html
Open Wc
Open Web Components: guides, tools and libraries for developing web components.
Stars: ✭ 1,670 (+950.31%)
Mutual labels:  web-components, lit-element
Monogatari
Monogatari is a simple web visual novel engine, created to bring Visual Novels to the web.
Stars: ✭ 357 (+124.53%)
Mutual labels:  progressive-web-app, web-components
redux-connect-element
Redux HTMLElement Connector
Stars: ✭ 16 (-89.94%)
Mutual labels:  lit-html, lit-element
highcharts-webcomponent
Highcharts Web Component usable with any Framework
Stars: ✭ 21 (-86.79%)
Mutual labels:  lit-html, lit-element
Smart Industry
🏭 Open Source Manufacturing Execution System for JobShop type manufacturer.
Stars: ✭ 138 (-13.21%)
Mutual labels:  progressive-web-app, web-components
Blog Pwa
An experiment in mixing Hugo, lit-element, and Polymer PRPL into a progressive web app blog.
Stars: ✭ 41 (-74.21%)
Mutual labels:  progressive-web-app, web-components

CI Built with pwa-lit-template

pwa-lit-template

Getting started | Build for production | Create a new page | Environment configuration | Service worker | Browser support

This project helps you to build Progressive Web Applications following the modern web standards, best practices and providing you with tools for that purpose. Out of the box, provides you with the following features:

  • Simple way to create Web Components with Lit.
  • Small and powerful client-side router for Web Components with Vaadin Router.
  • All the benefits from a PWA (manifest, service worker, offline UI) thanks to Workbox and pwa-helpers.
  • SEO friendly thanks to the PageElement custom element and the html-meta-manager.
  • A development server with auto-reload to serve the application without bundling with @web/dev-server.
  • Simple build flow thanks to Rollup and @open-wc/building-rollup initial configuration.
  • Easy deployment over to prpl-server or any static hosting.

Check out our roadmap to get informed of the latest features released and the upcoming ones.

Getting started

Prerequisites

Furthermore, this project is built on TypeScript with the intention of improving the developer experience.

Install the dependencies

npm install

Start the development server

This command serves the app at http://localhost:8000:

npm start

Project structure

├─ images/
├─ patches/
├─ server/
├─ src/
│  ├─ components/
│  │  ├─ app-index.ts
│  │  └─ ···
│  ├─ helpers/
│  │  ├─ page-element.ts
│  │  └─ ···
│  ├─ pages/
│  │  ├─ page-home.ts
│  │  └─ ···
│  ├─ router/
│  │  └─ routes.ts
│  └─ config.ts
├─ index.html
├─ manifest.webmanifest
├─ package.json
├─ robots.txt
├─ rollup.config.js
└─ tsconfig.json
  • images: is use to store the static resourced used by your application.
  • patches: contains the patches to apply in the different packages mentioned here. It will be removed at some point.
  • server: contains the logic to serve the application. And is where you are going to create your dist/ folder containing the bundle of your application.
  • src
    • components: contains your custom Web Components. Inside this folder you will find the app-index.ts file, main root of your application following the PRPL patern.
    • helpers: contains two interesting features: PageElement and html-meta-manager. Go more in-depth with them here.
    • pages: where you create the pages for your application.
    • router: where you create the routes for your application.
    • config.ts: stores the application configuration variables. Go more in-depth with it here.
  • index.html: the application entry point.

Guides

Build for production

This command use Rollup to build an optimized version of the application for production:

npm run build

It has two outputs: in addition to outputting a regular build, it outputs a legacy build which is compatible with older browsers down to IE11.

At runtime it is determined which version should be loaded, so that legacy browsers don't force to ship more and slower code to most users on modern browsers.

Note: If you need to add static files to the build, like the images folder or the manifest.webmanifest, you should register them in the copy() plugin of the rollup.config.js.

Create a new page

  1. Create the new page component (extending from PageElement helper) in the pages folder. For example a page-explore.ts.

    import { html } from 'lit';
    import { customElement } from 'lit/decorators.js';
    
    import { PageElement } from '../helpers/page-element.js';
    
    @customElement('page-explore')
    export class PageExplore extends PageElement {
      render() {
        return html`
          <h1>Explore</h1>
          <p>My new explore page!</p>
        `;
      }
    
      meta() {
        return {
          title: 'Explore',
          description: 'Explore page description',
        };
      }
    }
  2. Register the new route in the routes.ts:

    {
      path: '/explore',
      name: 'explore',
      component: 'page-explore',
      action: async () => {
        await import('../pages/page-explore.js');
      }
    },

With SEO in mind, this project offers you the PageElement base class to help you to deal with it; it has a meta() method that edits the HTML meta tags of the specific page. You must override that method to provide the data.

Environment configuration

This project allows different configurations per environment. The file that manages that configuration is src/config.ts. If you are interested in overwrite any of the configuration variables depending of the environment, you can create a file following the rule src/config.{NODE_ENV}.ts. Take into account that you don't need to replicate all the variables, just change the variable that you need to be different this way:

import config from './config.js';

export default {
  ...config,
  environment: 'staging',
};

In the build process the references in the project (but not in the configuration files) of ./config will be replaced to ./config.{NODE_ENV} loading the expected configuration file for the target environment.

Lastly, the way to use that configuration is quite simple. You only need to import it:

import config from '../config.js';

And use it where you need it:

render() {
  return html`
    <footer>
      <span>Environment: ${config.environment}</span>
    </footer>
  `;
}

Service worker

This project has configured the generation and injection of a service worker in the build process. But it is disabled by default. To enable it you just need to change the variable GENERATE_SERVICE_WORKER in the rollup.config.js to true.

Also you can change the Workbox configuration too modifying the variable workboxConfig in that same file.

Browser support

  • Chrome
  • Edge
  • Firefox
  • Safari

To run on other browsers, you need to use a combination of polyfills and transpilation. This step is automated by the build for production command.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].