Skip to content

Commit

Permalink
fix: add storybook again
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Dec 18, 2023
1 parent 110b1c7 commit 523b7f7
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx tsc --noEmit
npx tsc --noEmit -p tsconfig.build.json
npx lint-staged
29 changes: 0 additions & 29 deletions .storybook/main.js

This file was deleted.

33 changes: 33 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { StorybookConfig } from "@storybook/react-vite";
import path from "path";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
async viteFinal(config) {
// Set up aliases
(config.resolve as any).alias = {
...(config.resolve as any).alias,
"@": path.resolve(__dirname, "../src/"),
path: "path-browserify",
crypto: "crypto-browserify",
stream: "stream-browserify",
};

// Return the altered config
return config;
},
};
export default config;
23 changes: 0 additions & 23 deletions .storybook/preview.js

This file was deleted.

21 changes: 21 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "./tailwind.css";
import { Buffer } from "buffer";

window.global = window;
window.Buffer = window.Buffer || Buffer;

import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@
"dist"
],
"scripts": {
"build": "tsc --noEmit && vite build",
"build": "tsc --noEmit -p tsconfig.build.json && vite build",
"dev:vite": "vite build --watch --force",
"dev:tsc": "tsc --noEmit --watch",
"dev:tsc": "tsc -p tsconfig.build.json --noEmit --watch",
"prepare": "husky install",
"start": "concurrently npm:dev:*",
"check": "lint-staged",
"analyze": "npm run build && npx vite-bundle-visualizer",
"test": "jest",
"test:generate-output": "jest --json --outputFile=.jest-test-results.json",
"test:watch": "jest --watch"
"analyze": "npx vite-bundle-visualizer",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"antd": "^5.5.2",
Expand All @@ -72,6 +71,14 @@
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "10.0.4",
"@storybook/addon-essentials": "^7.6.5",
"@storybook/addon-interactions": "^7.6.5",
"@storybook/addon-links": "^7.6.5",
"@storybook/addon-onboarding": "^1.0.10",
"@storybook/blocks": "^7.6.5",
"@storybook/react": "^7.6.5",
"@storybook/react-vite": "^7.6.5",
"@storybook/test": "^7.6.5",
"@types/lodash": "^4.14.170",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
Expand All @@ -95,6 +102,7 @@
"prettier": "3.0.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"semantic-release": "21.0.7",
"storybook": "^7.6.5",
"typescript": "^5.0.4",
"vite": "^4.5.1",
"vite-bundle-visualizer": "^0.10.0",
Expand Down
11 changes: 11 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"dist",
"**/*.stories.*",
"**/*.test.*",
"**/*._test.*",
"**/*.mock.*"
]
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"exclude": [
"node_modules",
"dist",
"**/*.stories.*",
"**/*.test.*",
"**/*._test.*",
"**/*.mock.*"
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineConfig({
rollupOptions: {
// We manually add these since they are not directly in package.json, but they end up in the bundle if we don't exclude them.
// Reason for this is using imports for specific components
external: ["@ant-design/icons", "moment", "antd/es/alert/ErrorBoundary"],
external: ["@ant-design/icons", "dayjs", "antd/es/alert/ErrorBoundary"],
},
},
});

0 comments on commit 523b7f7

Please sign in to comment.