-
-
Notifications
You must be signed in to change notification settings - Fork 216
Expand file tree
/
Copy pathvite.config.ts
More file actions
97 lines (92 loc) · 3.82 KB
/
Copy pathvite.config.ts
File metadata and controls
97 lines (92 loc) · 3.82 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox and others.
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */
import { defineConfig } from 'vite';
import fs from 'node:fs';
import * as path from 'node:path';
import vsixPlugin from '@codingame/monaco-vscode-rollup-vsix-plugin';
const clangdWasmLocation = 'packages/examples/resources/clangd/wasm/clangd.wasm';
/// <reference lib="rolldown-vite/config" />
export const definedViteConfig = defineConfig({
build: {
rolldownOptions: {
input: {
index: path.resolve(__dirname, 'index.html'),
json_classic: path.resolve(__dirname, 'packages/examples/json_classic.html'),
json: path.resolve(__dirname, 'packages/examples/json.html'),
browser: path.resolve(__dirname, 'packages/examples/browser.html'),
langium_extended: path.resolve(__dirname, 'packages/examples/langium_extended.html'),
statemachine: path.resolve(__dirname, 'packages/examples/statemachine.html'),
python: path.resolve(__dirname, 'packages/examples/python.html'),
groovy: path.resolve(__dirname, 'packages/examples/groovy.html'),
clangd: path.resolve(__dirname, 'packages/examples/clangd.html'),
appPlayground: path.resolve(__dirname, 'packages/examples/appPlayground.html'),
twoLangaugeClients: path.resolve(__dirname, 'packages/examples/two_langauge_clients.html'),
reactAppPlayground: path.resolve(__dirname, 'packages/examples/react_appPlayground.html'),
reactStatemachine: path.resolve(__dirname, 'packages/examples/react_statemachine.html'),
reactPython: path.resolve(__dirname, 'packages/examples/react_python.html'),
tsExtHost: path.resolve(__dirname, 'packages/examples/tsExtHost.html'),
minilogo: path.resolve(__dirname, 'packages/examples/minilogo.html')
}
}
},
server: {
port: 20001,
host: '0.0.0.0',
cors: {
origin: '*'
},
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
},
watch: {
ignored: ['**/.chrome/**/*', './verify/**/*']
}
},
optimizeDeps: {
include: [
'@codingame/monaco-vscode-standalone-languages',
'@codingame/monaco-vscode-standalone-css-language-features',
'@codingame/monaco-vscode-standalone-html-language-features',
'@codingame/monaco-vscode-standalone-json-language-features',
'@codingame/monaco-vscode-standalone-typescript-language-features',
'@codingame/monaco-vscode-files-service-override',
'@testing-library/react',
'langium',
'langium/lsp',
'langium/grammar',
'vscode/localExtensionHost',
'vscode-jsonrpc',
'vscode-languageclient/browser',
'vscode-languageserver-protocol/browser',
'vscode-languageserver/browser'
]
},
plugins: [
{
// For the *-language-features extensions which use SharedArrayBuffer
name: 'configure-response-headers',
apply: 'serve',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
next();
});
}
},
vsixPlugin()
],
define: {
rootDirectory: JSON.stringify(__dirname),
// Server-provided Content-Length header may be gzipped, get the real size in build time
__WASM_SIZE__: fs.existsSync(clangdWasmLocation) ? fs.statSync(clangdWasmLocation).size : 0
},
worker: {
format: 'es'
}
});
export default definedViteConfig;