-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathvite.config.mts
66 lines (64 loc) · 1.9 KB
/
vite.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
import { versionForProject } from '../scripts/git-version.mjs'
import pkg from './package.json'
import path from 'path'
import { defineConfig } from 'vite'
import type { UserConfig } from 'vite'
export default defineConfig(
async (): Promise<UserConfig> => {
const project = process.env.OPENTRONS_PROJECT ?? 'robot-stack'
const version = await versionForProject(project)
return {
// this makes imports relative rather than absolute
base: '',
publicDir: false,
build: {
// Relative to the root
ssr: 'src/main.ts',
outDir: 'lib',
commonjsOptions: {
transformMixedEsModules: true,
esmExternals: true,
exclude: [/node_modules/],
},
lib: {
entry: {
main: 'src/main.ts',
preload: 'src/preload.ts',
},
formats: ['cjs'],
},
},
optimizeDeps: {
esbuildOptions: {
target: 'CommonJs',
},
exclude: ['node_modules'],
},
define: {
'process.env': {
NODE_ENV: process.env.NODE_ENV,
OPENTRONS_PROJECT: process.env.OPENTRONS_PROJECT,
},
global: 'globalThis',
_PKG_VERSION_: JSON.stringify(version),
_PKG_PRODUCT_NAME_: JSON.stringify(pkg.productName),
_PKG_BUGS_URL_: JSON.stringify(pkg.bugs.url),
_OPENTRONS_PROJECT_: JSON.stringify(project),
},
resolve: {
alias: {
'@opentrons/shared-data': path.resolve('../shared-data/js/index.ts'),
'@opentrons/step-generation': path.resolve(
'../step-generation/src/index.ts'
),
'@opentrons/discovery-client': path.resolve(
'../discovery-client/src/index.ts'
),
'@opentrons/usb-bridge/node-client': path.resolve(
'../usb-bridge/node-client/src/index.ts'
),
},
},
}
}
)