Adam Bien's Weblog

polymer 2.0 with browsersync: a minimal installation / hot reloading

For a minimal polymer (2.0) with browsersync (hot reloading) installation perform the following steps:

  1. Install www.npmjs.com
  2. Install bower.io with: sudo npm install -g bower
  3. Install browsersync.io with: sudo npm install -g browser-sync

Create bower.json with minimal dependencies:


{
  "name": "(...)",
  "main": "(...).html",
  "dependencies": {
    "polymer": "Polymer/polymer#^2.0.0-rc.2"
  },
  "devDependencies": {
    "webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0-rc.5"
  },
  "resolutions": {
    "polymer": "^2.0.0-rc.2"
  }
}
    

Execute: bower install

Maintain your code in src folder

Launch browsersync with with: browser-sync start --server src -f "**/*" --serveStatic ./bower_components -b "google chrome" --no-notify

Browsersync will open chrome, serve static files (polymer libs) from bower_components folder and watch src folder. Any changes are going to be automatically pushed to the browser without reloading. Skip the bower_components folder in all imports:

	
<link rel="import" href="polymer/polymer-element.html">
(...)
<script src="webcomponentsjs/webcomponents-lite.js"></script>
	
    

Also see sample project: github.com/AdamBien/polymer-essential

Interested in lean apps? See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Building HTML 5 Applications with WebStandards only


NEW workshop: HTML 5 and JavaScript Essentials, Three days in April 2017: from Java EE 7 Architectures over Microservices to Performance, Troubleshooting and Monitoring
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.

Newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License