How to install polymer

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:

  1. First install bower if not installed already.
  2. 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"
      ]
    }
    
  3. 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.

  4. View the bower.json again

    $ cat bower.json
    ...
    ...
      "dependencies": {
        "polymer": "^1.3.0"
      }
    }
    
  5. To include webcomponentsjs javascript files, regular script tag can be used. To include polymer html files the following code snippet can be used.
    <link rel="import" href="bower_components/polymer/polymer.html">
    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.
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments