Polymer App Creation Kit
An alternative to Polymer Starter Kit.
Just add water and stir.
Features
✓ Basic page layout using brand new app-layout
✓ Powerful routing using plain old app-router and pushstate-anchor
✓ Vulcanize configuration using web-component-shards for separate page bundles
✓ Pre-configured local-web-server with support for mocks, url rewrites and more
✓ Linting inline scripts with ESLint, including a Google config
✓ Linting inline styles with Stylelint, including a Polymer config
✓ Linting elements markup with HTMLHint
✓ Unit tests with WCT, including Istanbul plugin for coverage
✓ Transpiling ES2015 with Babel
✓ Scaffolding tasks for easy elements creation using Lo-Dash templates
✓ Simple and elegant project reset using renamer
Setup
npm i -g gulp bower
npm i
bower i
General tasks
Serve project from /src
gulp
Run production build
gulp build
Serve project from /dist
npm start
Project structure
Pack keeps components in separate directories.
src/
|
|-- components/ # Custom elements and behaviors
| |-- app/
| | |-- pack-app/ # Root endpoint required by index.html
| |
| |-- core/ # Smart components for app logic. They all should have tests
| | |-- pack-router/ # Wrapper component. Contains list of project routes
| | ...
| |
| |-- layout/ # Layout components, used on different pages
| | |-- pack-layout/ # Wrapper component. Contains layout skeleton
| | |-- pack-menu/ # Menu component built with some Paper Elements
| | ...
| |
| |-- pages/ # Page endpoints, lazy loaded by router
| |
| |-- shared/ # Reusable dummy components
| ...
|
|-- styles/ # Common style modules
| |-- shared-styles.html # Root style module shared between index.html and components
| |-- normalize.html # Normalize CSS
| |-- mixins.html # Shared mixins
| |-- variables.html # Shared variables
| ...
|
`-- vendor/ # Bower components
|-- polymer/ # Polymer library
|-- app-layout/ # Basic layout components
|-- app-router/ # Router component
...
Notes
- bower components directory (here called
vendor) must be placed into src to resolve imports by vulcanize
- so, if you want to place
vendor directory at project root, please create a symlink into src
- pay attention to components marked as endpoints: those are passed to web-component-shards
Scaffolding
Pack is designed to make your life easier.
Change app name and do magic:
gulp pack:rename
Note: generaly, you only should run this once after cloning this repo.
Pay attention to that package.json is used to get your app name.
By design, app name is also used as a prefix for all your elements.
Create new page:
gulp pack:page
Note: you should then add new page to pack-router manually.
Create new core element:
gulp pack:core
Note: you should then include element test into test/setup.html.
Linting
Run all lint tasks in parallel
npm run lint -s
Run JavaScript lint
npm run lint:js -s
Run HTML hint
npm run lint:html -s
Run stylelint
npm run lint:css -s
Note: only use -s flag locally if you don't need npm-debug.log
Testing
Run tests in Chrome:
npm test
Run tests in all browsers:
npm run test:all
Note: coverage report is opened only if your coverage exceeds required threshold.
FAQ
Why not using Polymer CLI?
Pack is designed to take full control over build process.
Why app-router?
Pack uses it for several reasons:
Please let me know when official app-route will implement all this stuff :)
Why web-component-shards?
Actually using wcs is the only way to split vulcanized app into several bundles.
In the future, polymer-build will be used instead.
Known issues
- Pack is not designed to run from subfolder on
gh-pages. I'm going to have a look at this later.
- Anyway, routing in that case is likely to be available only in
hash mode.
- Before running
pack:rename please make sure that you don't have some files opened in your IDE.
Leaving them opened might break magic of renamer (at least in Sublime).
- For transpiling ES2015, es2015-without-strict preset is used.
The reason is a bug in web-animations-next-lite.min.js used by neon-animated-pages. It doesn't work in strict mode.
For any ideas, feel free to email me at serguey.kulikov@gmail.com