-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.config.ts
55 lines (54 loc) · 1.6 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
43
44
45
46
47
48
49
50
51
52
53
54
55
import { resolve } from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dtsPlugin from "vite-plugin-dts";
export default defineConfig({
plugins: [
react(),
// This plugins generates global index.d.ts
dtsPlugin({
outDir: 'lib',
rollupTypes: true,
tsconfigPath: './tsconfig.build.json',
}),
],
build: {
target: ['es6'],
copyPublicDir: false,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
fileName: '[name]', // This parameter keeps the original filenames of the .ts(x)
formats: ['cjs'],
},
rollupOptions: {
// These dependencies are peer dependencies and should not be included in the packaged lib
external: [
'react',
'react/jsx-runtime',
'react-dom',
'styled-components',
'react-draft-wysiwyg',
'draftjs-to-html',
'html-to-draftjs',
'draft-js'
],
output: {
dir: 'lib',
interop: 'auto',
// These next 2 parameters are here to keep the structure of the src folder
preserveModules: true,
preserveModulesRoot: "./src",
generatedCode: {
/**
* Without this parameter, the library contains a lot of
* Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
* This string prevents right computation of tree shaking.
* This next parameter removes all of them:
* https://rollupjs.org/configuration-options/#output-generatedcode-symbols
*/
symbols: false,
}
}
}
}
});