-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
78 lines (75 loc) · 2.21 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { fromEnv } from '@nordicsemiconductor/from-env'
import { preact } from '@preact/preset-vite'
import chalk from 'chalk'
import { defineConfig } from 'vite'
import ssr from 'vike/plugin'
import { homepage, version } from './siteInfo.js'
import { dependencies } from './package.json'
const { registryEndpoint } = fromEnv({
registryEndpoint: 'REGISTRY_ENDPOINT',
})(process.env)
// Optional environment variables
const sentryDSN = process.env.SENTRY_DSN
if (sentryDSN === undefined) {
console.debug(chalk.yellow(`Sentry`), chalk.red('disabled'))
} else {
console.debug(chalk.yellow(`Sentry DSN`), chalk.blue(sentryDSN))
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
preact({
babel: {
plugins: ['@babel/plugin-syntax-import-assertions'],
},
}),
ssr({
prerender: true,
includeAssetsImportedByServer: true,
}),
],
base: `${(process.env.BASE_URL ?? '').replace(/\/+$/, '')}/`,
preview: {
host: 'localhost',
port: 8080,
},
server: {
host: 'localhost',
port: 8080,
},
resolve: {
alias: [
{ find: '#components/', replacement: '/src/components/' },
{ find: '#context/', replacement: '/src/context/' },
{ find: '#utils/', replacement: '/src/utils/' },
{ find: '#flows/', replacement: '/src/flows/' },
{ find: '#chart/', replacement: '/src/chart/' },
{ find: '#page/', replacement: '/src/page/' },
{ find: '#map/', replacement: '/src/map/' },
{ find: '#model/', replacement: '/src/model/' },
{ find: '#proto/', replacement: '/src/proto/' },
{ find: '#api/', replacement: '/src/api/' },
],
},
build: {
outDir: './build',
sourcemap: true,
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' },
},
// string values will be used as raw expressions, so if defining a string constant, it needs to be explicitly quoted
define: {
HOMEPAGE: JSON.stringify(homepage),
VERSION: JSON.stringify(version),
BUILD_TIME: JSON.stringify(new Date().toISOString()),
REGISTRY_ENDPOINT: JSON.stringify(registryEndpoint),
DOMAIN_NAME: JSON.stringify(
process.env.DOMAIN_NAME ?? 'hello.nrfcloud.com',
),
SENTRY_DSN: JSON.stringify(sentryDSN),
PROTO_MAP_VERSION: JSON.stringify(
dependencies['@hello.nrfcloud.com/proto-map'],
),
},
})