-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.main.config.mts
69 lines (62 loc) · 1.68 KB
/
vite.main.config.mts
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
61
62
63
64
65
66
67
68
69
import type { ConfigEnv, UserConfig } from 'vite'
import { defineConfig, loadEnv, mergeConfig } from 'vite'
import { getBuildConfig, getBuildDefine, external, pluginHotRestart } from './vite.base.config'
import tsconfigPaths from 'vite-tsconfig-paths'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { sentryVitePlugin } from '@sentry/vite-plugin'
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'build'>
const { forgeConfigSelf } = forgeEnv
const define = getBuildDefine(forgeEnv)
console.log('env.mode', env.mode)
const environment = loadEnv(env.mode, process.cwd(), '')
const plugins = [
pluginHotRestart('restart'),
tsconfigPaths(),
viteStaticCopy({
targets: [
{
src: 'assets',
dest: '.'
},
{
src: 'node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.wasm',
dest: '.'
}
]
})
]
// check if we are in a tag
const tag = process.env.GITHUB_REF?.includes('refs/tags/')
console.log('tag', tag)
if (tag) {
plugins.push(
sentryVitePlugin({
org: 'armaldio',
project: 'cyn',
authToken: environment.SENTRY_AUTH_TOKEN
})
)
}
const config: UserConfig = {
build: {
sourcemap: true,
lib: {
entry: forgeConfigSelf.entry!,
fileName: () => '[name].js',
formats: ['cjs']
},
rollupOptions: {
external
}
},
plugins,
define,
resolve: {
// Load the Node.js entry.
mainFields: ['module', 'jsnext:main', 'jsnext']
}
}
return mergeConfig(getBuildConfig(forgeEnv), config)
})