@@ -3,24 +3,37 @@ const filePath = require('path');
33
44function generateIframe ( ) : void {
55 const iframePath = filePath . join ( __dirname , '../storybook-static/iframe.html' ) ;
6- const indexPath = filePath . join ( __dirname , '../storybook-static/index.html' ) ;
76
87 if ( fileSystem . existsSync ( iframePath ) ) {
98 return ;
109 }
1110
12- if ( ! fileSystem . existsSync ( indexPath ) ) {
13- process . exit ( 1 ) ;
14- }
11+ const iframeContent = `<!DOCTYPE html>
12+ <html lang="en">
13+ <head>
14+ <meta charset="utf-8" />
15+ <title>Storybook Preview</title>
16+ <meta name="viewport" content="width=device-width, initial-scale=1" />
17+ <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
18+
19+ <style>
20+ body {
21+ margin: 0;
22+ padding: 0;
23+ }
24+ #storybook-root {
25+ height: 100vh;
26+ overflow: auto;
27+ }
28+ </style>
1529
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- ) ;
30+ <script type="module" src="./index.js"></script>
31+ </head>
32+ <body>
33+ <div id="storybook-root"></div>
34+ <div id="docs-root"></div>
35+ </body>
36+ </html>` ;
2437
2538 fileSystem . writeFileSync ( iframePath , iframeContent ) ;
2639}
0 commit comments