Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chromatic): generate webpack-stats.json with vite #229

Merged
merged 6 commits into from
Nov 3, 2023

Conversation

billhimmelsbach
Copy link
Contributor

@billhimmelsbach billhimmelsbach commented Nov 1, 2023

Chromatic's TurboSnap feature has been failing for awhile now, or perhaps never worked correctly? This small PR dug around to figure out why, and it looks like it's a problem with the creation of the preview-stats.json file. The passed command line option --webpack-stats-json to build-storybook in the package.json appears to be correct for webpack not vite. This PR uses Chromatic's recommended plugin vite-plugin-turbosnap to create the stats file. Take a look at the screenshots and commits for a history of attempted solutions.

Resolves issue #219

Changes

  • removes dead code --webpack-stats-json from build-storybook
  • add and configure vite-plugin-turbosnap

How to test this PR

This PR fixes the turbosnap configuration, but it still needs to run again with these updated deps to do diffs. I'm not sure if this is the only fix required, but it's definitely a start.

  1. Does Chromatic no longer error due to a missing webpack-stats.json file? Should now only be stating that it is disabled due to deps changes.

Screenshots

Before Fix: errors in GitHub action due to missing webpack-stats.json file
Screenshot 2023-11-01 at 6 11 37 PM

Before Fix: error in parsing file locally even when forcing webpack-stats.json file via WebpackStats() in vite. Error persists after name change. Parsing error tracked down to the fact that Chromatic expects a different format for the file than what vite normally produces.
Screenshot 2023-11-01 at 8 12 08 AM

After Fix: Configured the plugin, and TurboSnap is ready to go!

Screenshot 2023-11-01 at 6 20 00 PM

Copy link

netlify bot commented Nov 1, 2023

Deploy Preview for cfpb-design-system-react ready!

Name Link
🔨 Latest commit 7ab602b
🔍 Latest deploy log https://app.netlify.com/sites/cfpb-design-system-react/deploys/6542e552780b1f00080789f6
😎 Deploy Preview https://deploy-preview-229--cfpb-design-system-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@billhimmelsbach billhimmelsbach changed the title fix(chromatic): test directory issue fix(chromatic): generate webpack.stats with vite Nov 1, 2023
@billhimmelsbach billhimmelsbach changed the title fix(chromatic): generate webpack.stats with vite fix(chromatic): generate webpack-stats.json with vite Nov 1, 2023
@billhimmelsbach billhimmelsbach marked this pull request as ready for review November 2, 2023 15:35
Copy link
Contributor

@meissadia meissadia left a comment

Choose a reason for hiding this comment

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

Looks good 👍🏾

@billhimmelsbach billhimmelsbach merged commit 403124a into main Nov 3, 2023
@billhimmelsbach billhimmelsbach deleted the chromatic-bug-fix-tests branch November 3, 2023 23:30
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.

2 participants