Skip to content

Commit 0379b63

Browse files
Fixed deployment
1 parent 4d059d8 commit 0379b63

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

.storybook/generate-iframe.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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(/<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+
);
24+
25+
fileSystem.writeFileSync(iframePath, iframeContent);
26+
}
27+
28+
generateIframe();

.storybook/main.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff 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

1710
export default config;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
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",

0 commit comments

Comments
 (0)