-
Notifications
You must be signed in to change notification settings - Fork 216
Expand file tree
/
Copy pathvite.dspublisher.ts
More file actions
60 lines (51 loc) · 1.66 KB
/
vite.dspublisher.ts
File metadata and controls
60 lines (51 loc) · 1.66 KB
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
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import type { UserConfig } from 'vite';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const dspConfig = JSON.parse(
readFileSync(resolve(__dirname, 'dspublisher/config/default.json'), 'utf-8')
);
const docsPort = dspConfig.docsPort;
const allFlowImportsPath = resolve(__dirname, 'frontend/generated/flow/generated-flow-imports.js');
// vite.generated.ts accesses __dirname without declaring it.
// Workaround the error by setting it on the global object.
globalThis.__dirname = __dirname;
const { vaadinConfig } = await import('./vite.generated');
const vaadin = vaadinConfig({
mode: process.env.NODE_ENV ?? 'development',
command: 'build',
}) as UserConfig;
const endpointMocks = resolve(__dirname, 'frontend', 'demo', 'services', 'mocks.js');
// Use newer target to support top-level await in Hilla dependencies
const target = ['safari15', 'es2022'];
const config: UserConfig = {
resolve: {
alias: {
'Frontend/generated/endpoints': endpointMocks,
...vaadin.resolve?.alias,
'all-flow-imports-or-empty':
process.env.DOCS_IMPORT_EXAMPLE_RESOURCES === 'true' ? allFlowImportsPath : 'lit',
// Workaround https://github.com/preactjs/signals/issues/414
'@vaadin/hilla-react-signals': '@preact/signals-react',
},
},
server: {
/* dev-mode proxy config */
proxy: {
'/vaadin': {
target: `http://localhost:${docsPort}`,
},
},
},
build: {
target,
},
optimizeDeps: {
esbuildOptions: {
target,
},
},
};
export default config;