Storybook + Laravel Mix + Vue 3 + Tailwind 2

Skore Developers
2 min readMay 6, 2021

--

Sometimes is hard to use a software like Storybook which has been mainly developed with React and for React (and makes sense, after all, React is more UI focused than Vue).

In this article we’ll show how’d we setup Laravel Mix with Storybook to display and test visually our Vue 3 components, getting rid on all the problems.

Let’s give it a start!

First of all we’ll need to start a new Storybook project, so run the following command on the root folder of your project:

npx sb@next init — builder webpack5

After that you’ll see a couple of folders added to your project and some scripts on your package.json.

We’ll also need a PostCSS addon for Storybook, we can install it like so:

yarn add -D @storybook/addon-postcss

So after this we’ll need to write a couple of resolutions on this same file so we make sure that this doesn’t generate any conflicts with Tailwind’s PostCSS (in which PostCSS v8 is required in Tailwind v2), as we can read here.

package.json

After this run a yarn install.

Remember that this resolutions are Yarn only, if you’re using NPM you should use something like npm-force-resolutions.

Finally, this is how the 2 files generated by Storybook should look like:

main.js
preview.js

On the first main.js file, we just added a third item as an object on addons for use PostCSS with our own version (previously specified on the resolutions).

And last important bit, remember to add the CSS file of your application on the preview.js as Storybook doesn’t know it by default.

If you wanna see this working: See our example repository on Github.

Remember, this is an alpha version of Storybook on the date which this article is written. So any other problem related to it, just go to their repository and search or fill a new issue.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Skore Developers
Skore Developers

Written by Skore Developers

0 Followers

Welcome to our part of the internet where we share our technical tips and more! https://app.getskore.com

No responses yet

Write a response