0.1.44 • Published 2 years ago

create-lit-pwa v0.1.44

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Create Lit PWA

npm.io

To install, run

npm init lit-pwa@latest

Introduction

This is a simple template for a PWA that uses only native Web Components, with only Google's Lit library to make working with Web Components easier.

  • PWA Installable on desktop, tablet and mobile
  • Works offline
  • Passes all Lighthouse tests
  • TS and JS can be used simultaneously

Why Lit?

Lit handles smart reactive rendering in a way similar to React, but without the overhead of a Virtual DOM.\ It uses native ES String Literals and variables. Hence the name 'lit'.

import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
  static styles = css`p { color: blue }`;

  @property()
  name = 'Somebody';

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}

The library adds just 5KB to your bundle.\ šŸ’” Learn Lit:

Dev Tools

  • Uses TypeScript and ESLint for static analysis
  • Uses ESBuild for:
    • TypeScript compilation
    • Bundling
    • Development web server

VS Code Extensions

It is highly recommended to install following extensions:

  • esbenp.prettier-vscode
  • runem.lit-plugin
  • dbaeumer.vscode-eslint

Service worker

Lit PWA uses a service worker to implement the following features:

  • Installability
  • Work offline
  • Runtime caching
  • Serving index.html in case the server is not available or does not implement "spa behavior"

For day-to-day development, Lit PWA uses a 'Dev' service worker, which is "transparent" in the sense that it doesn't have any caching. Using this worker helps achieve a better development experience.

NPM scripts

We included 2 options for starting a development server, based on different development scenarios:

1: Common frontend development

  • 'Hot' browser reloading at every code change
  • 'Transparent' development service worker
npm start

2: Developing offline features, testing caching, running Lighthouse tests

  • Rebuild on change
  • No Live reloading
  • Fully functional service worker
npm run serve

Build for production:

npm run build

Run tests:

npm test

Debug tests:

npm run test:debug

Testing

Lit PWA uses @web/test-runner for testing. You can read more about it here:

https://modern-web.dev/guides/test-runner/getting-started https://modern-web.dev/guides/test-runner/watch-and-debug/ https://www.npmjs.com/package/web-test-runner-jasmine

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.40

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.26

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.4

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.3

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.2

2 years ago

0.0.11113

2 years ago

0.0.11112

2 years ago

0.0.11111

2 years ago

0.0.1111

2 years ago

0.0.111

2 years ago

0.0.11

2 years ago

0.0.1

2 years ago