A mininum boilerplate to deliver a LitElement 2.x with TypeScript, Webpack, PostCSS and Service Workers ready.
- Webpack 4
- webpack-dev-server with hot reloading active.
- PostCSS with many plugins.
- Service Workers generated by Workbox through the workbox-webpack-plugin (just for
build) - Copy statics file on
distfolder (likevendor/webcomponents-loader.jsand others) - standard-version is bundled for managing versioning and changelogs.
- babel-loader with the babel-preset-env and
babel-plugin-transform-object-rest-spreadinstalled. - text-loader - Used in conjunction with postcss-loader.
- postcss-loader - Load PostCSS into the
<style>scoped tag of Polymer elements as string.
All modern browsers. 🕶
But as the features said, we are also transpiling the bundle for "oldie" browsers. Of course we are not covering things like IE11.
Clone this repository:
git clone --depth 1 https://github.com/sipi/type-scripted-lit-element-skeleton [your-app-name]Remove the .git folder and change details within:
package.jsonsrc/manifest.json
Then start building your application!
yarnStart the webpack-dev-server on localhost http://localhost:3000 with hot-reload and watch on .pcss files.
yarn devXO for code style, Stylelint for PostCSS linting, and WCT for components tests:
yarn testRun Lighthouse for testing the PWA capabilities:
yarn test:lighthouse(Almost) production-ready (webpack --optimize-minimze and copy statics) to dist folder. Also generating Service Workers. The command will also create the module version of the bundle ready to be loaded as type=module.
yarn buildDuring development .pcss files will be watched, compiled and injected to the relative <style> tag within the component template. The CSS is scoped to the component so don't worry about CSS specificity, you can also use :host, :host-context and :root selectors. Read more about styling web components and custom CSS properties.
We also include Autoprefixer plugin, if you don't know how it works (...and you should), it allows you to write CSS without worrying about vendor prefixes. Just write your css properties prefix-free and let autoprefixer do the work for you when compiling.
How about commons styles?
You can simply import any other .pcss file within your main component .ts file and print it inside the render().
We are getting the webpcomponents-loader.js polyfill from GitHub using NPM/Yarn and copying it into a vendor folder with a Node script.
| Name | Website |
|---|---|
| Alessio Occhipinti | https://godev.space |
| Mattia Astorino | http://equinsuocha.io/ |
| Clément Sipieter | http://clement-sipieter.fr |
PolymerX © MIT Clément SIPIETER © MIT