chore: update react-styleguidist site build#351
Conversation
There was a problem hiding this comment.
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.
| @@ -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 | |||
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| "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" |
There was a problem hiding this comment.
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.
| "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" |
There was a problem hiding this comment.
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.
Description
Updates the react-styleguidist demo/site build for the current major version:
react-styleguidist@8toreact-styleguidist@13webpack-blockssetup with an explicit Webpack 5 +ts-loaderconfigplayground/srctreegenerate-styleguide.shand the styleguide npm scripts so builds run from the repository root and publish todocs/docs/bundleRelated issues
Verification
npm run styleguide:buildfromplayground/styleguidegit diff --checkChecklist
README_SOURCE.md(NOTREADME.md) - not applicable, no README content changesnpm run ci-checkto generate an updatedREADME.md- not applicable, no README content changes