fix(chromatic): generate webpack-stats.json with vite #229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
tobuild-storybook
in thepackage.json
appears to be correct for webpack not vite. This PR uses Chromatic's recommended pluginvite-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
--webpack-stats-json
frombuild-storybook
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.
Screenshots
Before Fix: errors in GitHub action due to missing

webpack-stats.json file
Before Fix: error in parsing file locally even when forcing

webpack-stats.json
file viaWebpackStats()
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.After Fix: Configured the plugin, and TurboSnap is ready to go!