Skip to content

Commit 056e080

Browse files
committed
Update package
Improve build and update package version with Vite
1 parent ea1524a commit 056e080

File tree

3 files changed

+114
-6
lines changed

3 files changed

+114
-6
lines changed

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kubit-ui-web/react-components",
3-
"version": "1.17.0",
3+
"version": "1.17.1",
44
"description": "Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience",
55
"author": {
66
"name": "Kubit",
@@ -16,9 +16,11 @@
1616
}
1717
},
1818
"private": false,
19-
"main": "./dist/cjs/index.js",
20-
"module": "./dist/esm/index.js",
21-
"types": "./dist/esm/index.d.ts",
19+
"main": "dist/kubit-react-components.cjs.js",
20+
"module": "dist/kubit-react-components.es.js",
21+
"unpkg": "dist/kubit-react-components.umd.js",
22+
"jsdelivr": "dist/kubit-react-components.umd.js",
23+
"types": "dist/types/index.d.ts",
2224
"engines": {
2325
"node": ">=20.x",
2426
"npm": ">=7.0.0"
@@ -60,7 +62,7 @@
6062
"storybook": "storybook dev -p 6006",
6163
"predist": "echo predist",
6264
"postdist": "cpy 'src/**/*.(svg|ttf|eot|css|png|jpg|otf)' dist/esm --no-overwrite --parents && cpy 'src/**/*.(svg|ttf|eot|css|png|jpg|otf)' dist/cjs --no-overwrite --parents",
63-
"dist": "rm -rf dist && yarn dist:cjs && yarn dist:esm",
65+
"dist": "rm -rf dist && yarn dist:cjs && yarn dist:esm && yarn run vite build --config vite.config.mts",
6466
"dist:watch": "rm -rf dist && yarn dist:cjs:watch & yarn dist:esm:watch",
6567
"dist:cjs": "tsc -p tsconfig-cjs.json && tsc-alias -p tsconfig-cjs.json",
6668
"dist:cjs:watch": "tsc -p tsconfig-cjs.json --watch & tsc-alias -p tsconfig-cjs.json --watch",
@@ -140,6 +142,7 @@
140142
"eslint-plugin-react-refresh": "^0.4.16",
141143
"eslint-plugin-storybook": "^0.11.1",
142144
"eslint-plugin-unused-imports": "^4.1.4",
145+
"glob": "^11.0.3",
143146
"globals": "^15.13.0",
144147
"gts": "^6.0.2",
145148
"html-validate": "^8.27.0",
@@ -153,13 +156,16 @@
153156
"json-beautify": "^1.1.1",
154157
"prettier": "^3.4.2",
155158
"react-transition-group": "^4.4.5",
159+
"rollup-plugin-terser": "^7.0.2",
156160
"sort-imports": "^1.1.0",
157161
"storybook": "^8.4.7",
158162
"ts-jest": "^29.2.5",
159163
"tsc-alias": "1.8.10",
160164
"typedoc": "^0.27.3",
161165
"typescript": "^5.7.2",
162-
"vite": "^6.0.3",
166+
"vite": "^7.0.0",
167+
"vite-plugin-dts": "^4.5.4",
168+
"vite-plugin-node-polyfills": "^0.23.0",
163169
"vite-tsconfig-paths": "^4.3.2",
164170
"yarn-deduplicate": "^6.0.2"
165171
},

tsconfig.build.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"exclude": [
3+
"src/**/*.test.*",
4+
"src/**/__mocks__",
5+
"src/**/__tests__",
6+
"src/**/*.mock.*",
7+
"dist",
8+
"vitest.config.ts",
9+
"vitest.setup.ts",
10+
"vite.config.mts"
11+
],
12+
"compilerOptions": {
13+
"target": "es2020",
14+
"lib": ["ES2015", "ES2016", "ES2021", "DOM"],
15+
"jsx": "react-jsx",
16+
"moduleResolution": "node",
17+
"module": "ESNext",
18+
"baseUrl": "./src",
19+
"paths": {
20+
"@/*": ["./*"],
21+
"fixtures/*": ["./__fixtures__/*"]
22+
},
23+
"typeRoots": ["src/types", "node_modules/@types"],
24+
"types": ["jest"],
25+
"resolveJsonModule": true,
26+
"checkJs": false,
27+
"noEmit": true,
28+
"allowSyntheticDefaultImports": true,
29+
"esModuleInterop": true,
30+
"forceConsistentCasingInFileNames": true,
31+
"strict": true,
32+
"noImplicitAny": false,
33+
"plugins": [],
34+
"skipLibCheck": true
35+
}
36+
}

vite.config.mts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import react from '@vitejs/plugin-react';
2+
3+
import fs from 'fs';
4+
import path from 'path';
5+
import { terser } from 'rollup-plugin-terser';
6+
import { defineConfig } from 'vite';
7+
8+
const copyRecursiveCSS = (srcDir: string, destDir: string) => {
9+
fs.mkdirSync(destDir, { recursive: true });
10+
11+
for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
12+
const srcPath = path.join(srcDir, entry.name);
13+
const destPath = path.join(destDir, entry.name);
14+
15+
if (entry.isDirectory()) {
16+
copyRecursiveCSS(srcPath, destPath);
17+
} else if (entry.name.endsWith('.css')) {
18+
fs.copyFileSync(srcPath, destPath);
19+
}
20+
}
21+
};
22+
23+
export default defineConfig({
24+
build: {
25+
lib: {
26+
entry: path.resolve(__dirname, 'src/index.ts'),
27+
fileName: format => `kubit-react-components.${format}.js`,
28+
formats: ['es', 'cjs', 'umd'],
29+
name: 'KubitReactComponents',
30+
},
31+
minify: 'terser',
32+
outDir: 'dist',
33+
rollupOptions: {
34+
external: ['react', 'react-dom'],
35+
output: {
36+
globals: {
37+
'react': 'React',
38+
'react-dom': 'ReactDOM',
39+
},
40+
plugins: [
41+
terser({
42+
compress: {
43+
drop_console: true,
44+
drop_debugger: true,
45+
},
46+
}),
47+
],
48+
},
49+
},
50+
terserOptions: {
51+
compress: {
52+
drop_console: true,
53+
drop_debugger: true,
54+
},
55+
},
56+
},
57+
define: {
58+
'process.env.NODE_ENV': JSON.stringify('production'),
59+
},
60+
plugins: [react()],
61+
resolve: {
62+
alias: {
63+
'@': path.resolve(__dirname, 'src'),
64+
},
65+
},
66+
});

0 commit comments

Comments
 (0)