File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed
Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 1+ const fileSystem = require ( 'fs' ) ;
2+ const filePath = require ( 'path' ) ;
3+
4+ function generateIframe ( ) : void {
5+ const iframePath = filePath . join ( __dirname , '../storybook-static/iframe.html' ) ;
6+ const indexPath = filePath . join ( __dirname , '../storybook-static/index.html' ) ;
7+
8+ if ( fileSystem . existsSync ( iframePath ) ) {
9+ return ;
10+ }
11+
12+ if ( ! fileSystem . existsSync ( indexPath ) ) {
13+ process . exit ( 1 ) ;
14+ }
15+
16+ const indexContent = fileSystem . readFileSync ( indexPath , 'utf8' ) ;
17+ const iframeContent = indexContent
18+ . replace ( / < t i t l e > .* ?< \/ t i t l e > / , '<title>Storybook Preview</title>' )
19+ . replace ( / < ! - - \s * S t o r y b o o k m a n a g e r .* ?- - > / g, '' )
20+ . replace (
21+ / < d i v i d = " s t o r y b o o k - m a n a g e r - r o o t " > [ \s \S ] * ?< \/ d i v > / ,
22+ '<div id="storybook-root"></div><div id="docs-root"></div>' ,
23+ ) ;
24+
25+ fileSystem . writeFileSync ( iframePath , iframeContent ) ;
26+ }
27+
28+ generateIframe ( ) ;
Original file line number Diff line number Diff line change @@ -4,14 +4,7 @@ const config = {
44 framework : {
55 name : '@stencil/storybook-plugin' ,
66 } ,
7- managerHead : ( head ) => `
8- ${ head }
9- <base href="./" />
10- ` ,
11- previewHead : ( head ) => `
12- ${ head }
13- <base href="./" />
14- ` ,
7+ staticDirs : [ '../dist/web-components' ] ,
158} ;
169
1710export default config ;
Original file line number Diff line number Diff line change 8686 "start" : " yarn run build:dev --watch --serve" ,
8787 "storybook-build-tailwind" : " npx ts-node .storybook/generate-safelist.ts && npx @tailwindcss/cli -i src/global/tailwind.css -o .storybook/tailwind.css --content '.storybook/tailwind-safelist.html' && rm -f .storybook/tailwind-safelist.html" ,
8888 "storybook-dev" : " yarn run build && yarn run storybook-build-tailwind && storybook dev -p 6006 --no-open" ,
89- "storybook-build" : " yarn run build && yarn run storybook-build-tailwind && storybook build"
89+ "storybook-build" : " yarn run build && yarn run storybook-build-tailwind && storybook build && npx ts-node .storybook/generate-iframe.ts "
9090 },
9191 "dependencies" : {
9292 "@stencil/core" : " ^4.36.2" ,
You can’t perform that action at this time.
0 commit comments