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', }, }; },