Skip to content

chore: update react-styleguidist site build#351

Open
leo1987820 wants to merge 2 commits into
piotrwitek:masterfrom
leo1987820:update-styleguidist-site
Open

chore: update react-styleguidist site build#351
leo1987820 wants to merge 2 commits into
piotrwitek:masterfrom
leo1987820:update-styleguidist-site

Conversation

@leo1987820

Copy link
Copy Markdown

Description

Updates the react-styleguidist demo/site build for the current major version:

  • upgrades the styleguide package from react-styleguidist@8 to react-styleguidist@13
  • replaces the old webpack-blocks setup with an explicit Webpack 5 + ts-loader config
  • resolves the styleguide source/components from the current playground/src tree
  • fixes generate-styleguide.sh and the styleguide npm scripts so builds run from the repository root and publish to docs/
  • refreshes the generated docs/ bundle

Related issues

Verification

  • npm run styleguide:build from playground/styleguide
  • git diff --check

Checklist

  • I have read CONTRIBUTING.md
  • I have edited README_SOURCE.md (NOT README.md) - not applicable, no README content changes
  • I have run CI script locally npm run ci-check to generate an updated README.md - not applicable, no README content changes
  • I have linked all related issues above
  • I have rebased my branch

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the styleguide configuration and dependencies, upgrading React to v18, Webpack to v5, and React Styleguidist to v13. It also replaces webpack-blocks with a custom Webpack configuration using ts-loader and updates paths to be absolute. Feedback focuses on simplifying and improving the robustness of the build scripts. Specifically, it is recommended to avoid relying on fragile relative paths and internal package entry points in both generate-styleguide.sh and package.json, opting instead for standard npm commands and local binary execution.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread generate-styleguide.sh Outdated
@@ -1,2 +1,2 @@
#!/bin/bash
cd playground && npm run styleguide:build
node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js build --config playground/styleguide/styleguide.config.js

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Executing scripts with relative paths directly from the shell is fragile because it depends on the current working directory (CWD) from which the script is run. If this script is executed from any directory other than the repository root, it will fail.

Additionally, invoking the internal CLI file of react-styleguidist (lib/bin/styleguidist.js) directly is an implementation detail that can break across package updates.

Instead, change the directory to the script's location first, and use npm --prefix to run the build script defined in package.json which safely resolves the local binary.

Suggested change
node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js build --config playground/styleguide/styleguide.config.js
cd "$(dirname "$0")"
npm --prefix playground/styleguide run styleguide:build

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in the current branch. generate-styleguide.sh now changes to the script directory first and delegates through npm --prefix playground/styleguide run styleguide:build, so it no longer relies on the caller's CWD or the internal react-styleguidist entry point.

Comment thread playground/styleguide/package.json Outdated
Comment on lines +11 to +12
"styleguide": "cd ../.. && node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js server --config playground/styleguide/styleguide.config.js",
"styleguide:build": "cd ../.. && node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js build --config playground/styleguide/styleguide.config.js"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

These scripts are overly complex and fragile because they change directories back to the root and invoke the internal entry point of react-styleguidist directly.

Since styleguide.config.js is located in this directory and uses absolute paths via path.join(__dirname, ...) for all configurations, styleguidist can be run directly from this directory without any directory traversal or custom config flags. This also avoids relying on internal package paths which may change in future updates.

Suggested change
"styleguide": "cd ../.. && node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js server --config playground/styleguide/styleguide.config.js",
"styleguide:build": "cd ../.. && node playground/styleguide/node_modules/react-styleguidist/lib/bin/styleguidist.js build --config playground/styleguide/styleguide.config.js"
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this suggestion locally. Running npx styleguidist build directly from playground/styleguide fails because styleguideDir resolves to the repository-level docs/ directory, which is outside that current working directory, and clean-webpack-plugin refuses to delete outside the CWD by default.

The current script keeps the working directory at the repository root while still using the public styleguidist CLI and explicit config path:

cd ../.. && styleguidist build --config playground/styleguide/styleguide.config.js

Verification:

cmd /c npm run styleguide:build
# Style guide published to ...\react-redux-typescript-guide\docs

cmd /c npx styleguidist build
# Error: clean-webpack-plugin: Cannot delete files/folders outside the current working directory.

So I am keeping the explicit root CWD here to preserve the repository-level docs output without enabling dangerous clean patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update react-styleguidist website

1 participant