forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
50 lines (44 loc) · 1.38 KB
/
vite.config.js
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
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
// TODO: Do build and package wasm-lsp separately. Right now vite does not
// support `exclude` in web workers!
import { defineConfig } from "vite";
export default defineConfig(({ command, _mode }) => {
const base_config = {
server: {
fs: {
// Allow serving files from the project root
allow: ["../../"],
},
},
base: "./",
};
let global_aliases = {
"@lsp/": "../../../lsp/pkg/",
};
if (command === "serve") {
// For development builds, serve the wasm interpreter straight out of the local file system.
base_config.resolve = {
alias: {
"@preview/": "../../../api/wasm-interpreter/pkg/",
...global_aliases,
},
};
} else {
// For distribution builds,
// assume deployment on the main website where the loading file (index.js) is in the assets/ sub-directory and the
// relative path to the interpreter is as below.
base_config.build = {};
base_config.build.rollupOptions = {
external: ["../../../../wasm-interpreter/slint_wasm_interpreter.js"],
input: ["index.html", "preview.html"],
};
base_config.resolve = {
alias: {
"@preview/": "../../../../wasm-interpreter/",
...global_aliases,
},
};
}
return base_config;
});