Skip to content

Commit 9a50de2

Browse files
build(sb): 👷 bring back webpack, babel & fix logo (#336)
1 parent 1f9420c commit 9a50de2

File tree

12 files changed

+474
-577
lines changed

12 files changed

+474
-577
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ yarn.lock
5555
dist
5656
CHANGELOG.md
5757
templates
58+
*.svg

.storybook/adaptui-tailwind.svg

Lines changed: 0 additions & 20 deletions
This file was deleted.

.storybook/main.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1-
const { mergeConfig } = require("vite");
2-
31
const config = {
42
framework: "@storybook/react",
5-
core: {
6-
builder: "@storybook/builder-vite",
7-
disableTelemetry: true,
8-
},
9-
async viteFinal(config: any, options: any) {
10-
return mergeConfig(config, {
11-
// customize the Vite config here
12-
build: {
13-
minify: false,
14-
sourcemap: false,
15-
},
16-
});
17-
},
18-
3+
core: { builder: "webpack5" },
194
// storyStoreV7 removes the circular dependency issue with Webpack 5
205
// So, we added ThemeProvider in preview.jsx and so src/theme should work for HMR
21-
features: { storyStoreV7: true },
22-
stories: ["../**/*.stories.@(ts|tsx)"],
6+
features: { storyStoreV7: true, babelModeV7: true },
7+
stories: ["../src/*/stories/*.stories.@(ts|tsx)"],
238
addons: [
24-
// "storybook-addon-preview",
9+
"storybook-addon-preview",
2510
"@storybook/addon-essentials",
2611
"@storybook/addon-a11y",
2712
{
@@ -33,6 +18,7 @@ const config = {
3318
},
3419
},
3520
],
21+
staticDirs: ["../assets"],
3622
};
3723

3824
module.exports = config;

.storybook/storybookTheme.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { create } from "@storybook/theming";
2-
const logo = require("./adaptui-tailwind.svg") as string;
32

43
export default create({
54
base: "light",
65
brandTitle: "AdaptUI React Tailwind",
76
brandUrl: "https://github.com/adaptui/react-tailwind",
8-
brandImage: logo,
7+
brandImage: "/logo.png",
98
brandTarget: "_self",
109
});

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"prettier.enable": true,
1414
"editor.formatOnSave": true,
1515
"editor.codeActionsOnSave": {
16-
"source.addMissingImports": true,
16+
"source.addMissingImports": true
1717
// "source.organizeImports": true,
1818
// "source.sortImports": true,
1919
// "source.fixAll": true

adaptui.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { extendTheme } from "./src";
22

33
export const theme = extendTheme({
4-
// This only affected the Storybook, doesn't go or merge when used this config as preset
4+
// This only affects the Storybook
55
extend: {
66
button: {
77
themeColor: {

assets/logo.png

42.9 KB
Loading

babel.config.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const BABEL_ENV = process.env.BABEL_ENV;
2+
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === "cjs";
3+
const isESM = BABEL_ENV !== undefined && BABEL_ENV === "esm";
4+
const isBuild = !!BABEL_ENV;
5+
6+
module.exports = function (api) {
7+
api.cache(true);
8+
9+
const presets = [
10+
[
11+
"@babel/env",
12+
{
13+
modules: isCommonJS ? "commonjs" : false,
14+
targets: { esmodules: isESM ? true : undefined },
15+
},
16+
],
17+
["@babel/preset-react", { runtime: "automatic" }],
18+
"@babel/preset-typescript",
19+
];
20+
21+
const plugins = [
22+
["@babel/plugin-proposal-private-methods", { loose: true }],
23+
["@babel/plugin-proposal-class-properties", { loose: true }],
24+
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
25+
isBuild
26+
? [
27+
"babel-plugin-jsx-remove-data-test-id",
28+
{ attributes: ["data-testid"] },
29+
]
30+
: {},
31+
];
32+
33+
return {
34+
presets,
35+
plugins,
36+
env: {
37+
test: {
38+
presets: [["@babel/env", { targets: { node: "current" } }]],
39+
},
40+
},
41+
ignore: isBuild
42+
? [
43+
"**/*/stories",
44+
"**/__tests__",
45+
"**/testUtils.tsx",
46+
"./renderlesskit.config.ts",
47+
]
48+
: [],
49+
};
50+
};

global.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

package.json

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
"swc:cjs": "swc src -d out/cjs -C module.type=commonjs --config-file .swcrc.build",
5757
"swc:esm": "swc src -d out/esm -C module.type=es6 --config-file .swcrc.build",
5858
"swc:types": "tsc --emitDeclarationOnly --project tsconfig.prod.json --declarationDir out/types",
59+
"prebabel": "rimraf dist",
60+
"babel": "yarn babel:cjs && yarn babel:esm",
61+
"postbabel": "yarn babel:types",
62+
"babel:cjs": "cross-env BABEL_ENV=cjs babel src --extensions .ts,.tsx -d dist/cjs --source-maps",
63+
"babel:esm": "cross-env BABEL_ENV=esm babel src --extensions .ts,.tsx -d dist/esm --source-maps",
64+
"babel:types": "tsc --emitDeclarationOnly --project tsconfig.prod.json --declarationDir dist/types",
5965
"storybook-build": "yarn previews && build-storybook",
6066
"prepublishOnly": "pinst --disable",
6167
"release": "release-it",
@@ -97,6 +103,14 @@
97103
"tailwind-merge": "^1.3.0"
98104
},
99105
"devDependencies": {
106+
"@babel/cli": "7.18.6",
107+
"@babel/core": "7.18.6",
108+
"@babel/plugin-proposal-class-properties": "7.18.6",
109+
"@babel/plugin-proposal-private-methods": "7.18.6",
110+
"@babel/plugin-proposal-private-property-in-object": "7.18.6",
111+
"@babel/preset-env": "7.18.6",
112+
"@babel/preset-react": "7.18.6",
113+
"@babel/preset-typescript": "7.18.6",
100114
"@commitlint/cli": "17.0.3",
101115
"@commitlint/config-conventional": "17.0.3",
102116
"@release-it/conventional-changelog": "5.0.0",
@@ -105,31 +119,33 @@
105119
"@storybook/addon-actions": "6.5.9",
106120
"@storybook/addon-essentials": "6.5.9",
107121
"@storybook/addon-postcss": "2.0.0",
108-
"@storybook/builder-vite": "^0.1.38",
122+
"@storybook/builder-webpack5": "6.5.9",
123+
"@storybook/manager-webpack5": "6.5.9",
109124
"@storybook/react": "6.5.9",
110125
"@swc/cli": "0.1.57",
111-
"@swc/core": "1.2.207",
126+
"@swc/core": "1.2.208",
127+
"@swc/jest": "0.2.21",
112128
"@tailwindcss/forms": "0.5.2",
113129
"@testing-library/dom": "8.14.0",
114130
"@testing-library/jest-dom": "5.16.4",
115131
"@testing-library/react": "13.3.0",
116132
"@testing-library/react-hooks": "8.0.1",
117133
"@testing-library/user-event": "14.2.1",
118-
"@types/jest": "28.1.3",
134+
"@types/jest": "28.1.4",
119135
"@types/jest-axe": "3.5.4",
120-
"@types/node": "18.0.0",
136+
"@types/node": "18.0.1",
121137
"@types/react": "18.0.14",
122138
"@types/react-dom": "18.0.5",
123139
"@types/testing-library__jest-dom": "5.14.5",
124140
"all-contributors-cli": "6.20.0",
125141
"autoprefixer": "10.4.7",
126142
"axe-core": "4.4.2",
127-
"@swc/jest": "0.2.21",
143+
"babel-plugin-jsx-remove-data-test-id": "3.0.0",
128144
"browserlist": "1.0.1",
129145
"chalk": "4.1.2",
130146
"concurrently": "7.2.2",
131147
"cross-env": "7.0.3",
132-
"eslint": "8.18.0",
148+
"eslint": "8.19.0",
133149
"eslint-config-prettier": "8.5.0",
134150
"eslint-config-react-app": "7.0.1",
135151
"eslint-plugin-prettier": "4.2.1",
@@ -148,14 +164,13 @@
148164
"patch-package": "6.4.7",
149165
"pinst": "3.0.0",
150166
"postcss": "8.4.14",
151-
"postcss-cli": "9.1.0",
167+
"postcss-cli": "10.0.0",
152168
"postcss-focus-visible": "6.0.4",
153169
"postcss-selector-parser": "6.0.10",
154170
"prettier": "2.7.1",
155171
"prettier-plugin-tailwindcss": "0.1.11",
156172
"react": "18.2.0",
157173
"react-dom": "18.2.0",
158-
"react-hook-form": "7.33.0",
159174
"react-icons": "4.4.0",
160175
"release-it": "15.1.1",
161176
"rimraf": "3.0.2",
@@ -164,7 +179,7 @@
164179
"storybook-addon-preview": "2.2.0",
165180
"tailwindcss": "3.1.4",
166181
"typescript": "4.7.4",
167-
"vite": "^2.9.13"
182+
"webpack": "5.73.0"
168183
},
169184
"peerDependencies": {
170185
"react": "16.x || 17.x || 18.x",

0 commit comments

Comments
 (0)