-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
48 lines (46 loc) · 1.22 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
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import postcssConfig from './postcss.config'
import { crx, ManifestV3Export } from '@crxjs/vite-plugin'
import manifest from './src/manifest'
import { viteStaticCopy } from 'vite-plugin-static-copy'
const SRC = resolve(__dirname, 'src')
// noinspection JSUnusedGlobalSymbols
export default defineConfig({
build: {
emptyOutDir: true,
outDir: resolve(__dirname, 'dist'),
rollupOptions: {
input: {
bg: resolve(SRC, 'bg', 'index.ts'),
popup: resolve(SRC, 'popup', 'index.html'),
},
output: {
entryFileNames: (chunkInfo): string => `src/${chunkInfo.name}/index.js`,
},
treeshake: {
moduleSideEffects: 'no-external',
preset: 'recommended',
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
},
},
},
css: {
postcss: postcssConfig,
},
plugins: [
react(),
crx({ manifest: manifest as ManifestV3Export }),
viteStaticCopy({
targets: [{ src: 'src/_locales/*', dest: '_locales' }],
}),
],
publicDir: resolve(__dirname, 'public'),
resolve: {
alias: {
'@': SRC,
},
},
})