Skip to content

Commit 97218ac

Browse files
Fixed deployment
1 parent 0379b63 commit 97218ac

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

.storybook/generate-iframe.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,37 @@ const filePath = require('path');
33

44
function 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(/<title>.*?<\/title>/, '<title>Storybook Preview</title>')
19-
.replace(/<!--\s*Storybook manager.*?-->/g, '')
20-
.replace(
21-
/<div id="storybook-manager-root">[\s\S]*?<\/div>/,
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

Comments
 (0)