-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
60 lines (58 loc) · 1.54 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
import { join } from 'path';
import { defineConfig } from 'vite';
import htmlConfig from 'vite-plugin-html-config';
import preact from '@preact/preset-vite';
import { VitePWA as pwa } from 'vite-plugin-pwa';
import svgr from '@svgr/rollup';
import tsconfigPaths from 'vite-tsconfig-paths';
import htmlConfigOptions from './config/html-config';
import manifestOptions from './config/manifest';
import workboxOptions from './config/workbox';
export default defineConfig({
build: {
cssCodeSplit: true,
emptyOutDir: true,
outDir: join(__dirname, './build'),
sourcemap: process.env.NODE_ENV !== 'production',
},
css: {
modules: {
generateScopedName:
process.env.NODE_ENV === 'production'
? '[hash:6]'
: '[name]_[local]__[hash:6]',
},
postcss: join(__dirname, './postcss.config.js'),
},
plugins: [
htmlConfig(htmlConfigOptions),
svgr({
plugins: [
'@svgr/plugin-svgo',
'@svgr/plugin-jsx',
'@svgr/plugin-prettier',
],
}),
tsconfigPaths({
root: __dirname,
}),
preact({ devtoolsInProd: false }),
pwa({
base: '/',
manifest: manifestOptions,
minify: process.env.NODE_ENV === 'production',
mode:
process.env.NODE_ENV === 'production' ? 'production' : 'development',
outDir: 'build',
registerType: 'autoUpdate',
workbox: workboxOptions,
}),
],
publicDir: join(__dirname, './public'),
resolve: {
alias: {
react: 'preact/compat',
},
},
root: join(__dirname, './src'),
});