-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mjs
49 lines (46 loc) · 1.03 KB
/
vite.config.mjs
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
//
// Copyright (c) 2023-2024 karamem0
//
// This software is released under the MIT License.
//
// https://github.com/karamem0/hitofude/blob/main/LICENSE
//
import {
defineConfig,
loadEnv
} from 'vite';
import fs from 'fs';
import reactPlugin from '@vitejs/plugin-react';
const htmlPlugin = (env) => ({
name: 'html-transform',
transformIndexHtml: {
order: 'pre',
handler: (html) => html.replace(/%(.*?)%/g, (match, p1) => env[p1] ?? match)
}
});
export default defineConfig(({ mode }) => ({
'plugins': [
reactPlugin({
'babel': {
'plugins': [
'@emotion/babel-plugin',
[
'formatjs',
{
ast: true,
idInterpolationPattern: '[sha512:contenthash:base64:6]'
}
]
]
},
'jsxImportSource': '@emotion/react'
}),
htmlPlugin(loadEnv(mode, '.'))
],
'server': {
'https': {
'cert': fs.readFileSync('./cert/localhost.crt'),
'key': fs.readFileSync('./cert/localhost.key')
}
}
}));