forked from delta/codecharacter-web-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.prod.config.ts
45 lines (44 loc) · 1.22 KB
/
vite.prod.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
import replace from '@rollup/plugin-replace';
import react from '@vitejs/plugin-react';
import path from 'path';
import { generateSW } from 'rollup-plugin-workbox';
import { defineConfig, Plugin } from 'vite';
export default defineConfig({
base: '',
build: {
minify: 'terser',
outDir: path.resolve(__dirname, 'dist'),
sourcemap: false,
terserOptions: {
format: { comments: false },
compress: true,
mangle: true,
},
rollupOptions: {
plugins: [
replace({
'typeof CANVAS_RENDERER': "'true'",
'typeof WEBGL_RENDERER': "'true'",
'typeof EXPERIMENTAL': "'false'",
'typeof PLUGIN_CAMERA3D': "'false'",
'typeof PLUGIN_FBINSTANT': "'false'",
'typeof FEATURE_SOUND': "'false'",
preventAssignment: true,
}) as Plugin,
] as Plugin[],
},
},
plugins: [
react(),
generateSW({
globIgnores: ['polyfills/*.js', 'nomodule-*.js'],
swDest: path.join('dist', 'sw.js'),
globDirectory: path.join('dist'),
globPatterns: ['**/*.{html,js,css,webp,png,webmanifest}'],
skipWaiting: true,
clientsClaim: true,
sourcemap: false,
inlineWorkboxRuntime: false,
}),
],
});