custom-elements-manifest.config.mjs (1472B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /** 6 * Custom element manifest analyzer plugin to remove static and private 7 * properties from custom-elements.json that we don't want to document in our 8 * Storybook props tables. 9 */ 10 function removePrivateAndStaticFields() { 11 return { 12 packageLinkPhase({ customElementsManifest }) { 13 customElementsManifest?.modules?.forEach(m => { 14 m?.declarations?.forEach(declaration => { 15 if (declaration.members != null) { 16 declaration.members = declaration.members.filter(member => { 17 return ( 18 !member.kind === "field" || 19 (!member.static && !member.name.startsWith("#")) 20 ); 21 }); 22 } 23 }); 24 }); 25 }, 26 }; 27 } 28 29 /** 30 * Custom element manifest config. Controls how we parse directories for custom 31 * elements to populate custom-elements.json, which is used by Storybook to 32 * generate docs. 33 */ 34 const config = { 35 globs: ["../../../toolkit/content/widgets/**/*.mjs"], 36 exclude: [ 37 "../../../toolkit/content/widgets/**/*.stories.mjs", 38 "../../../toolkit/content/widgets/vendor/**", 39 "../../../toolkit/content/widgets/lit-utils.mjs", 40 ], 41 outdir: ".", 42 litelement: true, 43 plugins: [removePrivateAndStaticFields()], 44 }; 45 46 export default config;