Polymer can be installed on Linux (or Mac) using bower on command line. It generates web component and polymer javascript files which can be included in your polymer project. Note that using polyfills, polymer works on almost all browsers.
Steps to install polymer:
- First install bower if not installed already.
-
Create a directory my_polymer_test_project and cd to it. Then run the bower init command
$ bower init ## Keep defaults for the purpose of this tutorial $ cat bower.json { "name": "my_polymer_test_project", "authors": [ "testauthor" ], "description": "", "main": "", "moduleType": [], "license": "MIT", "homepage": "", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ] }
-
Install polymer and save dependencies in bower.json
$ bower install polymer --save polymer#1.3.0 bower_components/polymer └── webcomponentsjs#0.7.21 webcomponentsjs#0.7.21 bower_components/webcomponentsjs $ ls -p bower_components/ polymer/ webcomponentsjs/
Not that it has also installed webcomponentsjs as polymer is dependent on it.
-
View the bower.json again
$ cat bower.json ... ... "dependencies": { "polymer": "^1.3.0" } }
-
To include webcomponentsjs javascript files, regular script tag can be used. To include polymer html files the following code snippet can be used.
Note that import have to be done either from same domain or Cross domain request need to be allowed from the domain serving polymer files.<link rel="import" href="bower_components/polymer/polymer.html">