-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
57 lines (52 loc) · 1.44 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
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", "esm", "cjs"];
// The library options for the different menus.
const lib = {
default: {
entry: resolve(__dirname, "build.js"),
name: "Graupl",
formats,
fileName: (format) => `graupl.${format}.js`,
},
Accordion: {
entry: resolve(__dirname, "/src/js/accordion/Accordion.js"),
name: "Accordion",
formats,
fileName: (format) => `component/accordion.${format}.js`,
},
Alert: {
entry: resolve(__dirname, "/src/js/alert/Alert.js"),
name: "Alert",
formats,
fileName: (format) => `component/alert.${format}.js`,
},
Carousel: {
entry: resolve(__dirname, "/src/js/carousel/Carousel.js"),
name: "Carousel",
formats,
fileName: (format) => `component/carousel.${format}.js`,
},
};
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: "dist/js",
lib: lib[buildType] || lib.default,
emptyOutDir: false,
},
server: {
host: "0.0.0.0",
hmr: {
host: "localhost",
},
},
});