-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
42 lines (39 loc) · 1.04 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import packageJSON from "./package.json";
const separators = new RegExp(/[-_/]+/, "g");
const nonWord = new RegExp(/[^\w\s]/, "g");
const firstLetterAfterSpace = new RegExp(/\s+(.)(\w*)/, "g");
const word = new RegExp(/\w/);
// From https://stackoverflow.com/questions/4068573/convert-string-to-pascal-case-aka-uppercamelcase-in-javascript
function toPascalCase(text: string) {
return text
.toLowerCase()
.replace(separators, " ")
.replace(nonWord, "")
.replace(
firstLetterAfterSpace,
(_, $2: string, $3: string) => `${$2.toUpperCase() + $3}`,
)
.replace(word, (s) => s.toUpperCase());
}
export default defineConfig({
build: {
lib: {
entry: "src/main.ts",
name: toPascalCase(packageJSON.name),
fileName: "main",
},
},
plugins: [
dts({
// rollupTypes: true,
exclude: [
"node_modules/**",
"src/**/vite-env.d.ts",
"src/**/*.spec.ts",
"vite.config.ts",
],
}),
],
});