Storybook: Storybook Docs for Web Components - how to use setCustomElements method for multiple component.

Created on 5 Apr 2020  路  4Comments  路  Source: storybookjs/storybook

setCustomElements method registor customElement Json to winto object how to change this file for multiple component

Can we have multiple customElements json in storybook app?

docs web-components question / support

Most helpful comment

generally there should only be one customElements.json per repository - it can hold information for multiple tags.

If you really need to split it up you will need to merge the data yourself with something like this (psoido code):

// there should only be one `customElements.json`- workaround for use more
const ce1 = require('../customElements.json');
const ce2 = require('../my-other-component/customElements.json');

const finalCe = {
  ...ce1, // probably not needed
  tags: [
    ...ce1.tags, 
    ...ce2.tags
  ]
}

All 4 comments

cc @daKmoR

@daKmoR - Can you please share your thoughts on above question.?

generally there should only be one customElements.json per repository - it can hold information for multiple tags.

If you really need to split it up you will need to merge the data yourself with something like this (psoido code):

// there should only be one `customElements.json`- workaround for use more
const ce1 = require('../customElements.json');
const ce2 = require('../my-other-component/customElements.json');

const finalCe = {
  ...ce1, // probably not needed
  tags: [
    ...ce1.tags, 
    ...ce2.tags
  ]
}

@daKmoR - Thanks for hint. It solved my problem, I ran into this issue because we are using Lerna for monorepo and my repo structure is bit complicated.

Thanks again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aericson picture aericson  路  97Comments

enagy27 picture enagy27  路  69Comments

ilyaulyanov picture ilyaulyanov  路  100Comments

43081j picture 43081j  路  61Comments

joeruello picture joeruello  路  79Comments