Skip to content

Commit 868ae06

Browse files
authored
chore: add a base directory for TurboSnap (#9258)
* Add base dir for TurboSnap * updated main workflow as well * Add vite configuration * remove the mergeConfig and return config
1 parent 69b5c9c commit 868ae06

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ jobs:
568568
# https://www.chromatic.com/docs/github-actions#forked-repositories
569569
projectToken: 695c25b6cb65
570570
workingDir: "./site"
571+
storybookBaseDir: "./site"
571572
# Prevent excessive build runs on minor version changes
572573
skip: "@(renovate/**|dependabot/**)"
573574
# Run TurboSnap to trace file dependencies to related stories
@@ -593,6 +594,7 @@ jobs:
593594
buildScriptName: "storybook:build"
594595
projectToken: 695c25b6cb65
595596
workingDir: "./site"
597+
storybookBaseDir: "./site"
596598
# Run TurboSnap to trace file dependencies to related stories
597599
# and tell chromatic to only take snapshots of relevent stories
598600
onlyChanged: true

site/.storybook/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import turbosnap from "vite-plugin-turbosnap"
2+
import { mergeConfig } from "vite"
3+
14
module.exports = {
25
stories: ["../src/**/*.stories.tsx"],
36
addons: [
@@ -11,4 +14,17 @@ module.exports = {
1114
name: "@storybook/react-vite",
1215
options: {},
1316
},
17+
async viteFinal(config, { configType }) {
18+
config.plugins = config.plugins || []
19+
// return the customized config
20+
if (configType === "PRODUCTION") {
21+
// ignore @ts-ignore because it's not in the vite types yet
22+
config.plugins.push(
23+
turbosnap({
24+
rootDir: config.root || "",
25+
}),
26+
)
27+
}
28+
return config
29+
},
1430
}

site/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"playwright:test": "playwright test --config=e2e/playwright.config.ts",
2222
"gen:provisioner": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./e2e/ --ts_proto_opt=outputJsonMethods=false,outputEncodeMethods=encode-no-creation,outputClientImpl=false,nestJs=false,outputPartialMethods=false,fileSuffix=Generated,suffix=hey -I ../provisionersdk/proto ../provisionersdk/proto/provisioner.proto && pnpm exec prettier --ignore-path '/dev/null' --cache --write './e2e/provisionerGenerated.ts'",
2323
"storybook": "STORYBOOK=true storybook dev -p 6006",
24-
"storybook:build": "storybook build --webpack-stats-json",
24+
"storybook:build": "storybook build",
2525
"test": "jest --selectProjects test",
2626
"test:ci": "jest --selectProjects test --silent",
2727
"test:coverage": "jest --selectProjects test --collectCoverage",
@@ -172,7 +172,8 @@
172172
"ts-node": "10.9.1",
173173
"ts-proto": "1.156.0",
174174
"typescript": "5.1.6",
175-
"vite-plugin-checker": "0.6.0"
175+
"vite-plugin-checker": "0.6.0",
176+
"vite-plugin-turbosnap": "1.0.2"
176177
},
177178
"browserslist": [
178179
"chrome 66",

site/pnpm-lock.yaml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)