Giter Club home page Giter Club logo

polymer-skeleton's Introduction

GitHub release Build Status GitHub issues XO code style Polymer Skeleton

Polymer Skeleton: Polymer 3 Progressive Web App (DEMO)

A mininum boilerplate to deliver a Polymer 3.x with Webpack, PostCSS and Service Workers ready. Made for personal use, glad if someone can get a good starting point from here. Bye bye Bower.

Features

Loaders

Supported Browsers

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.

Usage

Clone this repository:

git clone https://github.com/PolymerX/polymer-skeleton [your-app-name]

Remove the .git folder and change details within:

  • package.json
  • src/manifest.json

Then start building your application!

yarn

Developing

Start the webpack-dev-server on localhost http://localhost:3000 with hot-reload and watch on .pcss files.

For "oldie" browsers, transpiling also Javascript class. Works on Firefox:

yarn dev

For modern browsers with class support. Works on Chrome, Safari, and Edge:

yarn dev:module

Test

XO for code style, Stylelint for PostCSS linting, and WCT for components tests:

yarn test

Run Lighthouse for testing the PWA capabilities:

yarn test:lighthouse

Build

(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 build

Styling components with PostCSS

During 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 .js file and print it inside the template().

We are getting the webpcomponents-loader.js polyfill from GitHub using NPM/Yarn and copying it into a vendor folder with a Node script.

custom-element-es5-adpater.js

Loading the custom-element-es5-adapter.js is necessary because the custom elements known(1) issue(2) (the lovely Uncaught TypeError: Class constructor PolymerElement cannot be invoked without 'new') about ES6 classes, but just on old browsers.

Contributors

Name Website
Alessio Occhipinti https://godev.space
Mattia Astorino http://equinsuocha.io/

License

PolymerX ยฉ MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.