-
Notifications
You must be signed in to change notification settings - Fork 56
/
vite.config.ts
52 lines (49 loc) · 1.37 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
import { defineConfig } from 'vite'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import dts from 'vite-plugin-dts';
import path from 'path'
const injectCodeFunction = (cssCode) => {
try {
if (typeof window === 'undefined') return;
var elementStyle = document.createElement('style');
elementStyle.appendChild(document.createTextNode(cssCode));
document.head.appendChild(elementStyle);
} catch (e) {
console.error('vite-plugin-css-injected-by-js', e);
}
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
cssInjectedByJsPlugin({ injectCodeFunction }),
dts({
insertTypesEntry: true,
}),
// {
// name: "configure-response-headers",
// configureServer: (server) => {
// server.middlewares.use((_req, res, next) => {
// res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
// res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
// next();
// });
// },
// },
],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.tsx'),
name: 'AudioRecorder',
fileName: (format) => `react-audio-voice-recorder.${format}.js`,
formats: ["es"]
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
}
}
},
},
})