forked from giranm/pd-live-react
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.js
57 lines (55 loc) · 1.48 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
54
55
56
57
/* eslint-disable import/no-extraneous-dependencies */
import {
defineConfig,
} from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import eslint from 'vite-plugin-eslint';
function fixAcceptHeader404() {
return {
name: 'fix-accept-header-404', // issue with vite dev server: https://github.com/vitejs/vite/issues/9520
configureServer(server) {
server.middlewares.use((req, _res, next) => {
if (req.headers.accept === 'application/json, text/plain, */*') {
// eslint-disable-next-line no-param-reassign
req.headers.accept = '*/*';
}
next();
});
},
};
}
export default defineConfig(() => ({
base: '/pd-live-react',
server: {
host: '127.0.0.1',
port: 3000,
},
build: {
outDir: 'build',
sourcemap: true,
},
resolve: {
alias: {
src: '/src',
},
},
plugins: [
react({
babel: {
// Don't use .babelrc or babel.config.js files
babelrc: false,
configFile: false,
// preset-env won't work with Vite, so configure babel here
presets: [['@babel/preset-react', { runtime: 'automatic' }]],
plugins: ['@babel/plugin-transform-runtime'],
},
}),
EnvironmentPlugin('all', { loadEnvFiles: true }),
// svgr options: https://react-svgr.com/docs/options/
svgr({ include: '**/*.svg' }),
eslint(),
fixAcceptHeader404(),
],
}));