-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
40 lines (38 loc) · 1.19 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
import { defineConfig, UserConfigExport } from 'vite'
import { makeManifest } from './plugins/makeManifest';
import { replaceWord } from './plugins/replaceWord';
import { copyStatic } from './plugins/copyStatic';
import { parse, resolve } from 'path';
console.log('process ===> ', process.env.BROWSER, process.env.NODE_ENV);
const isChrome = process.env.BROWSER === undefined ? true : process.env.BROWSER === 'chrome';
const from = isChrome ? 'browser' : 'chrome'; // this var for replaceWord plugin
const to = isChrome ? 'chrome' : 'browser'; // this var for replaceWord plugin
// https://vitejs.dev/config/
export default defineConfig({
root: 'src',
publicDir: 'public',
build: {
rollupOptions: {
input: {
index: resolve(__dirname, 'src', 'index.html')
},
output: {
dir: "dist",
chunkFileNames: "[name].[hash].js",
entryFileNames: "[name].js",
assetFileNames: (assetInfo:any) => {
const { name } = parse(assetInfo.name);
return `${name}.[ext]`;
},
},
}
},
plugins: [
{
...replaceWord({ from, to }),
enforce: 'pre'
},
copyStatic('public'),
makeManifest()
]
} as UserConfigExport);