Skip to content

Commit d1bfd5b

Browse files
Merge pull request #1287 from CleverCloud/storybook/switch-to-clever-static-app
chore(storybook): switch to static Clever App
2 parents 1b6862d + 30bfb4b commit d1bfd5b

File tree

4 files changed

+37
-114
lines changed

4 files changed

+37
-114
lines changed

.storybook/.htaccess

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
RewriteEngine On
2+
3+
# If an existing asset or directory is requested, serve it
4+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
5+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
6+
RewriteRule ^ - [L]
7+
8+
# If the requested resource doesn't exist, use index.html
9+
RewriteRule ^ /index.html
10+
11+
<IfModule mod_headers.c>
12+
<FilesMatch "\.(js|html)$">
13+
Header set Cache-Control "no-cache"
14+
</FilesMatch>
15+
16+
<FilesMatch "\.(css)$">
17+
Header set Cache-Control "max-age=2592000, immutable"
18+
</FilesMatch>
19+
20+
<FilesMatch "\.(svg|woff2)$">
21+
Header set Cache-Control "max-age=31536000, immutable"
22+
</FilesMatch>
23+
</IfModule>

.storybook/main.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy from 'rollup-plugin-copy';
12
import generateCem from '../cem/generate-cem-vite-plugin.js';
23
import { markdownIndexer } from '../src/stories/lib/markdown-indexer.js';
34
import { rollupMdToCsfPlugin } from '../src/stories/lib/markdown-to-csf.js';
@@ -64,7 +65,19 @@ const config = {
6465

6566
if (configType === 'PRODUCTION') {
6667
customConfig = {
67-
plugins: commonPlugins,
68+
plugins: [
69+
...commonPlugins,
70+
// The clever cloud Storybook static app needs a `.htaccess` at the root of `storybook-static`
71+
// @ts-expect-error type error related to the plugin but our usage matches the docs
72+
copy({
73+
targets: [
74+
{
75+
src: `.storybook/.htaccess`,
76+
dest: config.build.outDir,
77+
},
78+
],
79+
}),
80+
],
6881
};
6982
}
7083

package-lock.json

Lines changed: 0 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"preview:get": "node tasks/preview.js get",
4545
"preview:list": "node tasks/preview.js list",
4646
"preview:publish": "node tasks/preview.js publish",
47-
"start": "static -H '{\"cache-control\": \"no-cache, no-store, must-revalidate\", \"Pragma\": \"no-cache\", \"Expires\": \"0\"}' -a 0.0.0.0 -p 8080 storybook-static",
4847
"storybook:build": "storybook build -o storybook-static${STORYBOOK_PATH}",
4948
"storybook:dev": "storybook dev -p 6006 --no-open",
5049
"stylelint": "stylelint src/components/*/*.js",
@@ -131,7 +130,6 @@
131130
"lit-analyzer": "2.0.0-pre.3",
132131
"mime-types": "^2.1.30",
133132
"mocha": "^10.0.0",
134-
"node-static": "^0.7.11",
135133
"postcss-styled-syntax": "^0.7.0",
136134
"prettier": "^3.2.5",
137135
"prettier-plugin-organize-imports": "^4.0.0",

0 commit comments

Comments
 (0)