-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvite.config.ts
70 lines (64 loc) · 1.78 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { rmSync } from 'fs';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import electron from 'vite-plugin-electron';
import Unocss from 'unocss/vite';
import presetUno from '@unocss/preset-uno';
import presetIcons from '@unocss/preset-icons';
import presetAttributify from '@unocss/preset-attributify';
import transformerDirective from '@unocss/transformer-directives';
import esmodule from 'vite-plugin-esmodule';
import pkg from './package.json';
const { join, resolve } = require('path');
rmSync(join(__dirname, 'dist-electron'), { recursive: true, force: true }); // v14.14.0
const isDev = process.env.NODE_ENV === 'development';
const isProd = process.env.NODE_ENV === 'production';
// https://vitejs.dev/config/
export default defineConfig({
build: {
target: 'esnext',
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
styles: resolve(__dirname, 'src/assets/styles'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.less'],
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
plugins: [
react(),
electron([{
entry: ['electron/main.ts', 'electron/preload.ts', 'electron/worker/backup.ts', 'electron/utils/recommendConfigs/index.ts'],
vite: {
mode: process.env.NODE_ENV,
build: {
minify: isProd,
watch: isDev ? {} : null,
},
},
},
]),
Unocss({
presets: [
presetUno({ dark: 'class' }),
presetAttributify(),
presetIcons({
/* options */
}),
],
transformers: [transformerDirective()],
}),
esmodule(['fs-extra']),
],
server: {
host: pkg.env.VITE_DEV_SERVER_HOST,
port: pkg.env.VITE_DEV_SERVER_PORT,
},
});