creevey icon indicating copy to clipboard operation
creevey copied to clipboard

Storybook 6.3 + Vite support?

Open adiun opened this issue 3 years ago • 5 comments

Storybook 6.3 introduced Vite support. Vite replaces webpack for us in our toolchain, greatly improves build speed, and works great with Storybook as of 6.3.

We've been running creevey for some time on local machines and in CI, it works well for us. When I try to run creevey with this new Vite setup I get this error:

[CreeveyWebpack]: Starting with pid 46200
[FAIL:46200] TypeError: builder.overridePresets is not iterable
    at getWebpackConfigForStorybook_6_2 (/Users/adi/Documents/Projects/Terminal2/node_modules/creevey/lib/server/webpack/index.js:180:94)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.compile [as default] (/Users/adi/Documents/Projects/Terminal2/node_modules/creevey/lib/server/webpack/index.js:247:34)

I could be wrong but from these errors I'm getting it looks like creevey depends on the webpack configuration in Storybook. Will or does creevey support the new Vite features for Storybook?

adiun avatar Jul 04 '21 18:07 adiun

@adiun Hi, thanks for the issue. I made a feature for loading stories without webpack, but didn't test it with Vite. I have a flag useWebpackToExtractTests in config which rules how to load stories. If you are using Storybook 6.3 and even 6.2 it should work well and Creevey shouldn't load webpack. It looks like a bug.

The flag is false by default for Storybook >= 6.2 and true for older versions. It's set here https://github.com/wKich/creevey/blob/ae3c6b712a8e41a7d3f4396b269d471c578d9408/src/server/config.ts#L54

wKich avatar Jul 05 '21 14:07 wKich

I'm using webpack only to compile Creevey client UI bundle for npm package, that's why it listed in devDeps

wKich avatar Jul 05 '21 14:07 wKich

@adiun, Hi. I didn't see that error while fixing creevey to work with Vite. But I checked, that Creevey works in your monorepo project with vite and also it works on a fresh clean vite project.

I released 0.7.33 with those fixes. Please, check it out. And feel free to ask me if something goes wrong.

wKich avatar Jul 12 '21 10:07 wKich

Thank you @wKich! I will check it out. The issue I'm running into is that I'm trying to run creevey --extract to create a stories.json for my storybook project (which I am using to publish the storybook) which hits this error. Have you tried that with Vite? I will give it a shot later today as well.

adiun avatar Jul 12 '21 14:07 adiun

@adiun no I didn't. But I'm pretty sure if creevey starts tests without any errors, the extract will work as well, because it reuse same logic to get stories meta.

The one important issue that I found is Creevey doesn't work well with monorepos, I mean that Creevey work with only one storybook config at the time. So you need to have root storybook setup and the same for Creevey, or have to use Creevey per each package inside a monorepo like here https://github.com/adiun/vite-monorepo/pull/1

wKich avatar Jul 12 '21 16:07 wKich