1

I started on a project and wanted to wrap up a component and then share it to another project, however because of company constraints I can't publish it to github as per the documentation suggests. I managed to share the component through IIS, however I am not sure if this is the best way, as the desired result is having a CDN like way of referencing components into applications.

Here is the code:

This is the component that i want to share: base-element.html

<!-- Imports polymer -->
<link rel="import" href="bower_components/polymer/polymer.html">

<!-- Defines element markup -->
<dom-module id="base-element">
    <template>
     <h3>Hello</h3>
    </template>
    <!-- Registers custom element -->
<script>
Polymer({
    is: 'base-element',

    // Fires when an instance of the element is created
    created: function() {},

    // Fires when the local DOM has been fully prepared
    ready: function() {},

    // Fires when the element was inserted into the document
    attached: function() {},

    // Fires when the element was removed from the document
    detached: function() {},

    // Fires when an attribute was added, removed, or updated
    attributeChanged: function(attr, oldVal, newVal) {}
});
</script>
</dom-module>

Here is the bower.json file:

{
  "name": "base-element",
  "private": true,
  "dependencies": {
    "polymer": "Polymer/polymer#^1.2.0"
  },
  "devDependencies": {
    "web-component-tester": "^4.0.0"
  },
  "ignore": []
}

In IIS i setup this as the main application then I setup a virtual app called client which then references this html file.

In the index.html file of the client app

  <script src="bower_components/webcomponentsjs/webcomponents.js"></script>
    <!-- endbower -->
    <!-- endbuild -->
    <link rel="import" href="../base-element.html"/>

Then in the view that I want to display the component:

<base-element></base-element>

This functions however, it would be nice if I could achieve this using grunt serve or something. Any suggestions?

leeroya
  • 485
  • 7
  • 12
  • I am a bit puzzled as to what you are trying to do in your index.html file, then were does an href with two dots supposed to point at. Remember this is web url space not your filesystem. – akc42 Feb 01 '16 at 22:57

2 Answers2

0

A an idea, see my answer to my own question here How can I replace the server in Web Component Tester

This suggests using a proxy server to forward requests at for your base element to your main running server. (or another instance using a nodejs style server).

Community
  • 1
  • 1
akc42
  • 4,893
  • 5
  • 41
  • 60
  • Thanks for this, I will give it a try as my solution works and you can add listeners to IIS applications but will give your suggestion a try – leeroya Feb 02 '16 at 09:42
0

See if this helps - Using Bower as the Package Management tool for Internal, Private Libraries

You can share your component via a private repository and this can be included as a bower dependency. Check the documentation.