From ebac0cbd4294ea83173b1ce3010a8634da7dcd72 Mon Sep 17 00:00:00 2001 From: Reuben Ellis Date: Tue, 22 Aug 2023 15:07:52 -0600 Subject: [PATCH 1/4] Add base dir for TurboSnap --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5510e0005b9ce..b16a785c1ce65 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -568,6 +568,7 @@ jobs: # https://www.chromatic.com/docs/github-actions#forked-repositories projectToken: 695c25b6cb65 workingDir: "./site" + storybookBaseDir: "./site" # Prevent excessive build runs on minor version changes skip: "@(renovate/**|dependabot/**)" # Run TurboSnap to trace file dependencies to related stories From a553b2b7cbdc34cec4d36e639f556c119a74dc6c Mon Sep 17 00:00:00 2001 From: Reuben Ellis Date: Tue, 22 Aug 2023 15:13:22 -0600 Subject: [PATCH 2/4] updated main workflow as well --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b16a785c1ce65..98ad7eafc1ad3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -594,6 +594,7 @@ jobs: buildScriptName: "storybook:build" projectToken: 695c25b6cb65 workingDir: "./site" + storybookBaseDir: "./site" # Run TurboSnap to trace file dependencies to related stories # and tell chromatic to only take snapshots of relevent stories onlyChanged: true From 3bd1ad1a7504ddb09796b2a592a0840464be6ce7 Mon Sep 17 00:00:00 2001 From: Reuben Ellis Date: Tue, 22 Aug 2023 16:07:19 -0600 Subject: [PATCH 3/4] Add vite configuration --- site/.storybook/main.js | 18 ++++++++++++++++++ site/package.json | 5 +++-- site/pnpm-lock.yaml | 7 +++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/site/.storybook/main.js b/site/.storybook/main.js index f22249ddbfe83..f1ad2bf02cd26 100644 --- a/site/.storybook/main.js +++ b/site/.storybook/main.js @@ -1,3 +1,6 @@ +import turbosnap from "vite-plugin-turbosnap" +import { mergeConfig } from "vite" + module.exports = { stories: ["../src/**/*.stories.tsx"], addons: [ @@ -11,4 +14,19 @@ module.exports = { name: "@storybook/react-vite", options: {}, }, + async viteFinal(config, { configType }) { + config.plugins = config.plugins || [] + // return the customized config + if (configType === "PRODUCTION") { + // ignore @ts-ignore because it's not in the vite types yet + config.plugins.push( + turbosnap({ + rootDir: config.root || "", + }), + ) + } + return mergeConfig(config, { + // Your environment configuration here + }) + }, } diff --git a/site/package.json b/site/package.json index 8976fe4659399..61d94eab3b232 100644 --- a/site/package.json +++ b/site/package.json @@ -21,7 +21,7 @@ "playwright:test": "playwright test --config=e2e/playwright.config.ts", "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'", "storybook": "STORYBOOK=true storybook dev -p 6006", - "storybook:build": "storybook build --webpack-stats-json", + "storybook:build": "storybook build", "test": "jest --selectProjects test", "test:ci": "jest --selectProjects test --silent", "test:coverage": "jest --selectProjects test --collectCoverage", @@ -172,7 +172,8 @@ "ts-node": "10.9.1", "ts-proto": "1.156.0", "typescript": "5.1.6", - "vite-plugin-checker": "0.6.0" + "vite-plugin-checker": "0.6.0", + "vite-plugin-turbosnap": "1.0.2" }, "browserslist": [ "chrome 66", diff --git a/site/pnpm-lock.yaml b/site/pnpm-lock.yaml index 00d76bb9c3efc..1c9e2c91be819 100644 --- a/site/pnpm-lock.yaml +++ b/site/pnpm-lock.yaml @@ -431,6 +431,9 @@ devDependencies: vite-plugin-checker: specifier: 0.6.0 version: 0.6.0(eslint@8.46.0)(typescript@5.1.6)(vite@4.4.2) + vite-plugin-turbosnap: + specifier: 1.0.2 + version: 1.0.2 packages: @@ -13277,6 +13280,10 @@ packages: vscode-uri: 3.0.7 dev: true + /vite-plugin-turbosnap@1.0.2: + resolution: {integrity: sha512-irjKcKXRn7v5bPAg4mAbsS6DgibpP1VUFL9tlgxU6lloK6V9yw9qCZkS+s2PtbkZpWNzr3TN3zVJAc6J7gJZmA==} + dev: true + /vite@4.4.2(@types/node@18.17.0): resolution: {integrity: sha512-zUcsJN+UvdSyHhYa277UHhiJ3iq4hUBwHavOpsNUGsTgjBeoBlK8eDt+iT09pBq0h9/knhG/SPrZiM7cGmg7NA==} engines: {node: ^14.18.0 || >=16.0.0} From 3554988d33bb8831c90cbd56a617291dbe6c90ed Mon Sep 17 00:00:00 2001 From: Reuben Ellis Date: Wed, 23 Aug 2023 08:49:20 -0600 Subject: [PATCH 4/4] remove the mergeConfig and return config --- site/.storybook/main.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/site/.storybook/main.js b/site/.storybook/main.js index f1ad2bf02cd26..6fed6b2997d30 100644 --- a/site/.storybook/main.js +++ b/site/.storybook/main.js @@ -25,8 +25,6 @@ module.exports = { }), ) } - return mergeConfig(config, { - // Your environment configuration here - }) + return config }, }