-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.build.mjs
More file actions
40 lines (38 loc) · 824 Bytes
/
vite.build.mjs
File metadata and controls
40 lines (38 loc) · 824 Bytes
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 { build } from 'vite';
import { config } from 'dotenv';
import { exec } from 'child_process';
config({
path: process.env.NODE_ENV === 'development' ? '.env.development' : undefined,
});
build({
configFile: false,
build: {
emptyOutDir: true,
lib: {
entry: './src/index.ts',
formats: ['es', 'cjs'],
name: 'index',
fileName: 'index',
},
outDir: 'lib',
watch: process.argv.includes('--watch'),
rollupOptions: {
external: ['ofetch', '@microsoft/fetch-event-source'],
},
},
define: {
'process.env': {
NODE_ENV: process.env.NODE_ENV,
API_URL: process.env.API_URL,
CDN_URL: process.env.CDN_URL,
},
},
plugins: [
{
name: 'postbuild-commands',
closeBundle: () => {
exec('tsc');
},
},
],
});