From deef8abca5d9936afcb85896ba6f344947b9aee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Thu, 1 Aug 2024 10:44:44 +0200 Subject: [PATCH 1/6] :wrench: Enable storybook to be served from a subdir --- docker/devenv/files/nginx.conf | 5 +++++ frontend/package.json | 1 + frontend/vite.config.js | 7 +++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docker/devenv/files/nginx.conf b/docker/devenv/files/nginx.conf index 05df881bd..961b3a4fb 100644 --- a/docker/devenv/files/nginx.conf +++ b/docker/devenv/files/nginx.conf @@ -149,6 +149,11 @@ http { proxy_pass http://127.0.0.1:6060/ws/notifications; } + location /storybook { + alias /home/penpot/penpot/frontend/storybook-static/; + autoindex on; + } + location / { location ~ ^/github/penpot-files/(?[a-zA-Z0-9\-\_\.]+) { proxy_pass https://raw.githubusercontent.com/penpot/penpot-files/main/$template_file; diff --git a/frontend/package.json b/frontend/package.json index 9a527d9c0..fee783f99 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -36,6 +36,7 @@ "e2e:server": "node ./scripts/e2e-server.js", "e2e:test": "playwright test --project default", "storybook:compile": "yarn run compile && clojure -M:dev:shadow-cljs compile storybook", + "storybook:release": "yarn run compile && clojure -M:dev:shadow-cljs compile storybook && yarn run storybook build", "storybook:server": "yarn run storybook dev -p 6006 --no-open", "storybook:watch": "concurrently \"clojure -M:dev:shadow-cljs watch storybook\" \"yarn run storybook:server\" \"yarn run watch\"", "storybook:build": "yarn run storybook:compile && storybook build" diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 119e8e7aa..12cc3eeb8 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -1,15 +1,14 @@ import { defineConfig } from "vite"; -import { configDefaults } from 'vitest/config' +import { configDefaults } from "vitest/config"; import { resolve } from "path"; // https://vitejs.dev/config/ export default defineConfig({ test: { - exclude: [...configDefaults.exclude, 'target/**', 'resources/**'], - environment: 'jsdom' + exclude: [...configDefaults.exclude, "target/**", "resources/**"], + environment: "jsdom", }, - resolve: { alias: { "@target": resolve(__dirname, "./target/storybook"), From 8bcc2a4932c2db176835298a347507d9663f25b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Thu, 1 Aug 2024 14:54:57 +0200 Subject: [PATCH 2/6] :sparkles: Compile storybook target in release and a separate DS stylesheet --- frontend/.storybook/preview-head.html | 2 +- frontend/package.json | 4 +-- frontend/scripts/_helpers.js | 41 +++++++++++++++++++++++++++ frontend/scripts/compile-storybook.js | 7 +++++ frontend/shadow-cljs.edn | 2 +- 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 frontend/scripts/compile-storybook.js diff --git a/frontend/.storybook/preview-head.html b/frontend/.storybook/preview-head.html index e943079ee..9985b3804 100644 --- a/frontend/.storybook/preview-head.html +++ b/frontend/.storybook/preview-head.html @@ -1,4 +1,4 @@ - + \ No newline at end of file + diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index 34e7c00fd..b8fbd0de5 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -404,6 +404,15 @@ async function generateTemplates() { ); await fs.writeFile("./.storybook/preview-body.html", content); + content = await renderTemplate( + "resources/templates/preview-head.mustache", + { + manifest: manifest, + }, + partials, + ); + await fs.writeFile("./.storybook/preview-head.html", content); + content = await renderTemplate("resources/templates/render.mustache", { manifest: manifest, translations: JSON.stringify(translations),