-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
53 lines (52 loc) · 1.55 KB
/
vite.config.js
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import path from 'path';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import tailwind from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import tailwindConfig from './tailwind.config';
export default defineConfig({
plugins: [react(), nodePolyfills({ include: ['events'] }),
cssInjectedByJsPlugin({
injectCode: (cssCode, options) => `try {
if(typeof document != 'undefined') {
const elementStyle = document.createElement('style');
elementStyle.id = 'react-tw-ai-client';
elementStyle.appendChild(document.createTextNode(${cssCode}));
document.body.appendChild(elementStyle);
}
} catch(e) {
console.error('vite-plugin-css-injected-by-js', e);
}`
})],
resolve: {
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
},
server: {
host: '0.0.0.0',
port: 5173,
},
css: {
postcss: {
plugins: [tailwind(tailwindConfig), autoprefixer],
},
},
build: {
lib: {
entry: path.resolve(__dirname, './src/main.jsx'),
name: 'ReactBotClient',
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
output: { exports: 'auto' },
external: [
'react', 'react-dom', 'react-redux',
'redux-persist', 'socket.io-client', '@reduxjs/toolkit',
'prop-types', 'events', 'react-markdown'
],
},
sourcemap: true,
emptyOutDir: true,
},
});