Skip to content

Commit

Permalink
Install & Setup Storybook
Browse files Browse the repository at this point in the history
# @types/react との競合について
storybookjs/storybook#12505vuejs/language-tools#592 に言及されている通り
@types/react と競合し型エラーが発生する。
対策として @types/react の削除、tsconfig からの stories.ts の除外が考えられるが今回は前者を選択した
理由は @types/react を使用しないことが明確であり、stories.ts にはしっかり tsconfig を適応していからである。
  • Loading branch information
HosokawaR committed Mar 21, 2022
1 parent cbb9f9a commit ee378e5
Show file tree
Hide file tree
Showing 6 changed files with 7,251 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"settings": {},
"extensions": ["dbaeumer.vscode-eslint", "johnsoncodehk.volar"],
"forwardPorts": [3000],
"forwardPorts": [3000, 6006],
"postCreateCommand": "yarn install",
"remoteUser": "node"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist
dist-ssr
*.local
tsconfig.staged.json
storybook-static
20 changes: 20 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require("path")
const { loadConfigFromFile, mergeConfig } = require("vite");

module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
framework: "@storybook/vue3",
core: {
builder: "storybook-builder-vite",
},
async viteFinal(config, { configType }) {
const { config: userConfig } = await loadConfigFromFile(
path.resolve(__dirname, "../vite.config.ts")
);
return mergeConfig(config, {
...userConfig,
plugins: [],
});
},
};
11 changes: 11 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "~/scss/main.scss";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"lint:fix": "yarn lint --fix",
"test": "jest",
"apigen": "rm -rf src/api && npx openapi2aspida",
"prepare": "husky install"
"prepare": "husky install && rimraf ./node_modules/@types/react",
"storybook": "start-storybook -p 6006",
"build-storybook": "yarn typecheck && build-storybook"
},
"dependencies": {
"@aspida/axios": "^1.6.3",
Expand All @@ -34,6 +36,11 @@
"vuex": "4"
},
"devDependencies": {
"@babel/core": "^7.17.8",
"@storybook/addon-actions": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-links": "^6.4.19",
"@storybook/vue3": "^6.4.19",
"@types/jest": "26.0.22",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^5.15.0",
Expand All @@ -43,6 +50,7 @@
"@vue/eslint-config-typescript": "7.0.0",
"@vue/tsconfig": "^0.1.3",
"autoprefixer": "9.8.6",
"babel-loader": "^8.2.3",
"esbuild-jest": "0.4.0",
"eslint": "7.23.0",
"eslint-config-prettier": "8.1.0",
Expand All @@ -53,11 +61,13 @@
"prettier": "2.2.1",
"rollup": "^2.44.0",
"sass": "1.32.8",
"storybook-builder-vite": "^0.1.21",
"tailwindcss": "1.9.6",
"ts-node": "9.1.1",
"typescript": "^4.6.2",
"vite": "2.1.4",
"vue-eslint-parser": "7.6.0",
"vue-loader": "^16.8.3",
"vue-tsc": "^0.33.2"
}
}
Loading

0 comments on commit ee378e5

Please sign in to comment.