-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.js
65 lines (60 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { resolve } from "path";
import { defineConfig } from "vite";
import { fileURLToPath, URL } from "url";
import process from "process";
// Get the current directory path.
const __dirname = fileURLToPath(new URL(".", import.meta.url));
// The type of menu to build from the BUILD_TYPE environment variable.
// If BUILD_TYPE is not set, the default build is used
const buildType = process.env.BUILD_TYPE ?? "default";
// Supported build types.
const formats = ["iife", "es", "cjs"];
// The library options for the different menus.
const lib = {
default: {
entry: resolve(__dirname, "build.js"),
name: "AccessibleMenu",
formats,
fileName: (format) => `accessible-menu.${format}.js`,
},
DisclosureMenu: {
entry: resolve(__dirname, "/src/disclosureMenu.js"),
name: "DisclosureMenu",
formats,
fileName: (format) => `disclosure-menu.${format}.js`,
},
Menubar: {
entry: resolve(__dirname, "/src/menubar.js"),
name: "Menubar",
formats,
fileName: (format) => `menubar.${format}.js`,
},
TopLinkDisclosureMenu: {
entry: resolve(__dirname, "/src/topLinkDisclosureMenu.js"),
name: "TopLinkDisclosureMenu",
formats,
fileName: (format) => `top-link-disclosure-menu.${format}.js`,
},
Treeview: {
entry: resolve(__dirname, "/src/treeview.js"),
name: "Treeview",
formats,
fileName: (format) => `treeview.${format}.js`,
},
};
// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: lib[buildType] || lib.default,
emptyOutDir: false,
},
server: {
host: "0.0.0.0",
},
test: {
environment: "jsdom",
environmentOptions: {
pretendToBeVisual: true,
},
},
});