Next 13 + Tilewind に Storybook 7 インストール
2023-02-19IT記事,Next.jsNext.js,Storybook,Tilewind
記事日付 2023/02/18
環境
- Windows11 (WSL)
- “next": “13.1.6"
- “tailwindcss": “^3.2.7"
- “storybook": “^7.0.0-beta.50"
storybookのインストールまたはupdate
npx storybook@next init
npx storybook@next upgrade --prerelease"’ compilationWARN Force closed preview build ModuleNotFoundError: Module not found: Error: Can’t resolve 'style-loader’ in "’ といったエラー.
@storybook/addon-postcssのインストール
npm install --save-dev @storybook/addon-postcss
または
yarn add -D @storybook/addon-postcss.storybook/main.ts を変更。ついでにstoriesフォルダの指定も変えます。
import type { StorybookConfig } from '@storybook/nextjs'
const config: StorybookConfig = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
'../app/**/*.mdx',
'../app/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
],
framework: {
name: '@storybook/nextjs',
options: {},
},
docs: {
autodocs: 'tag',
},
}
export default configtilewindの読み込み。.storybook/preview.ts
import '../app/globals.css';
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};satisfiesを使っていたら以下のエラー
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
* ./node_modules/unplugin/dist/webpack/loaders/load.js
You may need an additional loader to handle the result of these loaders.
| }
| }
> } satisfies Meta<typeof Button>);
| export default meta;わからん。とりあえずsatisfies使わない。 例
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'
const meta: Meta<typeof UserPrompt> = {
title: 'Button',
component: Button,
}
export default meta
type Story = StoryObj<typeof meta>
export const Default: Story = {
args: {
...
},
}(まだexampleでエラー出てるけど)とりあえず動いた。
関連記事

[Amplify + Next.js] 簡単な掲示板を作成
前にReactで作った掲示板をNextにしてみる。SSRをまず使ってみる。 ne ...

AWS AmplifyとVue.jsで認証画面
AWS Amplifyの認証まわり、ログイン画面からやってみる。amplify ...

リンクを投稿できるだけのサイトを作ってみた
aws amplify の勉強を兼ねてリンクを投稿できるだけのサイトを作ってみた ...

AWS Amplifyでマーダーミステリー用Webツールを作ってみた
AWS Amplifyで(Zoom とか Google Meet併用前提の)マー ...

なろう小説apiを叩いてみる
なろう小説でなにかツールでも作れないかなーと、とりあえず提供されているapiを叩 ...
ディスカッション
コメント一覧
Hubetapp looks handy! Gonna download it now and see what the mobile experience is like. Ease of use is key for me. Hope it’s smooth! hubetapp