From 189426c15963012b1ea79441faf0727ad6b7cdf7 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Wed, 20 Sep 2023 11:58:08 +0200 Subject: [PATCH 1/3] Setup TurboSnap --- .github/workflows/chromatic.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index b6220efd..d37a9534 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -15,4 +15,7 @@ jobs: - name: Publish to Chromatic uses: chromaui/action@v1 with: + externals: | + - 'public/**' + onlyChanged: true projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} From b9d89e3969c49985392df55512360d8be9b5b61c Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Wed, 20 Sep 2023 12:47:23 +0200 Subject: [PATCH 2/3] Add vite-plugin-turbosnap --- .storybook/main.ts | 12 +++++++++++- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.storybook/main.ts b/.storybook/main.ts index 2cb53881..dab29077 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,4 +1,7 @@ import type { StorybookConfig } from "@storybook/react-vite"; +import { mergeConfig } from "vite"; +import turbosnap from "vite-plugin-turbosnap"; + import { CHROMATIC_BASE_URL } from "../src/constants"; const useDistVersion = process.env.CHROMATIC_USE_DIST_VERSION === "true"; @@ -34,14 +37,21 @@ const config: StorybookConfig = { name: "@storybook/react-vite", options: {}, }, + logLevel: "debug", staticDirs: ["../public"], stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], - logLevel: "debug", refs: { "@storybook/components": { title: "@storybook/components", url: "https://next--635781f3500dd2c49e189caf.chromatic.com", }, }, + async viteFinal(config, { configType }) { + const rootDir = config.root ?? process.cwd(); + return mergeConfig(config, { + plugins: configType === "PRODUCTION" ? [turbosnap({ rootDir })] : [], + }); + }, }; + export default config; diff --git a/package.json b/package.json index cf24c861..054b715e 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,7 @@ "typescript": "^4.9.5", "vite": "^4.1.4", "vite-plugin-environment": "^1.1.3", + "vite-plugin-turbosnap": "^1.0.3", "zx": "^1.14.1" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 8dc87dc5..d69ea009 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13119,6 +13119,11 @@ vite-plugin-environment@^1.1.3: resolved "https://registry.yarnpkg.com/vite-plugin-environment/-/vite-plugin-environment-1.1.3.tgz#d01a04abb2f69730a4866c9c9db51d3dab74645b" integrity sha512-9LBhB0lx+2lXVBEWxFZC+WO7PKEyE/ykJ7EPWCq95NEcCpblxamTbs5Dm3DLBGzwODpJMEnzQywJU8fw6XGGGA== +vite-plugin-turbosnap@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/vite-plugin-turbosnap/-/vite-plugin-turbosnap-1.0.3.tgz#5519bc7b5f8e9c589e8d11fb6b053ec086f41f0a" + integrity sha512-p4D8CFVhZS412SyQX125qxyzOgIFouwOcvjZWk6bQbNPR1wtaEzFT6jZxAjf1dejlGqa6fqHcuCvQea6EWUkUA== + vite@^4.1.4: version "4.4.9" resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d" From a91e3de5ab6c90dcf19e38dbe704fc0a373b0277 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Fri, 22 Sep 2023 09:38:48 +0200 Subject: [PATCH 3/3] Update Chromatic config for TurboSnap --- production.config.json | 4 ++++ staging.config.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/production.config.json b/production.config.json index 449e8d19..4f750258 100644 --- a/production.config.json +++ b/production.config.json @@ -1,4 +1,8 @@ { + "autoAcceptChanges": "main", + "exitOnceUploaded": true, + "externals": ["public/**"], + "onlyChanged": true, "projectId": "Project:6480e1b0042842f149cfd74c", "projectToken": "chpt_5a1a378a1392c49", "zip": true diff --git a/staging.config.json b/staging.config.json index bffcbf04..c4860e96 100644 --- a/staging.config.json +++ b/staging.config.json @@ -1,4 +1,8 @@ { + "autoAcceptChanges": "main", + "exitOnceUploaded": true, + "externals": ["public/**"], + "onlyChanged": true, "projectToken": "chpt_fdc053b44dc78f3", "projectId": "Project:64936c844fd570be8b75bdac", "zip": true