react-core (storybook, prettier, tailwindcss) 환경 설정
2023-06-11
아래 명령어는 core 환경 설정하려고 쳤던 명령어 입니다. 순서가 조금 이상한거 같은데, 다음에 제대로 해서 다시 올리도록 하겠습니다.
아래의 vs code 확장 프로그램도 설치 해주었습니다.
- Tailwind CSS IntelliSense
- Prettier - Code formatter
-
스토리북 설치
npx storybook@latest init
-
.storybook/main.js
/** @type { import('@storybook/react-webpack5').StorybookConfig } */ const config = { stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], addons: [ '@storybook/addon-links', '@storybook/addon-essentials', '@storybook/preset-create-react-app', '@storybook/addon-interactions', { name: '@storybook/addon-styling', options: { // Check out https://github.com/storybookjs/addon-styling/blob/main/docs/api.md // For more details on this addon's options. postCss: true, }, }, ], framework: { name: '@storybook/react-webpack5', options: {}, }, docs: { autodocs: 'tag', }, staticDirs: ['../public'], }; export default config;
-
.storybook/preview.js
/** @type { import('@storybook/react').Preview } */ import '../src/index.css'; // replace with the name of your tailwind css file const preview = { parameters: { actions: { argTypesRegex: '^on[A-Z].*' }, controls: { matchers: { color: /(background|color)$/i, date: /Date$/, }, }, }, }; export default preview;
-
-
prettier 및 prettier-plugin-tailwindcss 설치
npm install -D prettier prettier-plugin-tailwindcss
-
prettier 설치
npm install --save-dev prettier
-
.prettierrc.js
module.exports = { singleQuote: true, trailingComma: 'all', printWidth: 100, };
-
prettier.config.js
module.exports = { plugins: [require('prettier-plugin-tailwindcss')], tailwindConfig: './styles/tailwind.config.js', };
-
-
storybook cli 설치
npx @storybook/cli sb init
-
sb 업그레이드
npx sb@latest upgrade
-
postcss 설치 같음
npm i -D @storybook/addon-styling postcss autoprefixer
-
postcss.config.js
module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };
-
-
tailwindcss 설치
npm install -D tailwindcss npx tailwindcss init
-
src/index.css
@tailwind base; @tailwind components; @tailwind utilities; body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; }
-
tailwind.config.js
/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./src/**/*.{js,jsx,ts,tsx}", ], theme: { extend: {}, }, plugins: [], }
-
-
next 설치
npx create-next-app next-storybook
-
tailwindcss 설치
npx tailwindcss init -p