-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathvite.config.ts
37 lines (35 loc) · 1.06 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
import replace from '@rollup/plugin-replace';
import react from '@vitejs/plugin-react';
import fs from 'fs';
import path from 'path';
import { defineConfig } from 'vite';
import mkcert from 'vite-plugin-mkcert';
const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8'));
const dateString = new Date().toISOString().replace('T', ' @ ').replace(/\..+/, '');
const appVersion = `${packageJson.version as string} (${dateString})`;
const replaceOptions = {
__APP_VERSION__: appVersion,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
preventAssignment: true,
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
replace(replaceOptions),
mkcert({
savePath: 'certs',
keyFileName: 'key.pem',
certFileName: 'cert.pem',
}),
],
server: {
https: true,
host: '127.0.0.1',
port: JSON.parse(process.env.PORT || '4000'),
},
build: {
outDir: 'build',
sourcemap: true,
},
});