From ed1e40204a6f093aed961cacb93d2ce9bbb00b83 Mon Sep 17 00:00:00 2001 From: louwie17 Date: Thu, 26 Sep 2024 09:24:29 -0300 Subject: [PATCH] Add composition path prefix to storybook to allow publishing to gh-pages (#51700) Add composition path prefix to storybook --- .github/workflows/storybook-pages.yml | 2 ++ tools/storybook/.storybook/main.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/storybook-pages.yml b/.github/workflows/storybook-pages.yml index 1aea3190d65..55e72e9adb8 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -27,6 +27,8 @@ jobs: - name: Build Storybook run: pnpm --filter='@woocommerce/storybook' build-storybook --quiet + env: + STORYBOOK_COMPOSITION_PATH_PREFIX: /woocommerce - name: Deploy uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 diff --git a/tools/storybook/.storybook/main.js b/tools/storybook/.storybook/main.js index e3b012cc58b..e2ae6320a5d 100644 --- a/tools/storybook/.storybook/main.js +++ b/tools/storybook/.storybook/main.js @@ -28,11 +28,18 @@ module.exports = { if ( configType === 'DEVELOPMENT' ) { return {}; } + + let pathPrefix = ( + process.env.STORYBOOK_COMPOSITION_PATH_PREFIX ?? '' + ).trim(); + if ( pathPrefix && ! pathPrefix.startsWith( '/' ) ) { + pathPrefix = '/' + pathPrefix; + } return { 'woocommerce-blocks': { expanded: false, title: 'WooCommerce Blocks', - url: '/assets/woocommerce-blocks', + url: pathPrefix + '/assets/woocommerce-blocks', }, }; },