forked from Diuke/polimi-webgis-class-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
103 lines (91 loc) · 3.88 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
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
98
99
100
101
102
103
// import { globSync } from 'glob';
// import path from 'node:path';
// import { fileURLToPath } from 'node:url';
// // config options
// export default {
// // Complete documentation of Vite configuration on
// // https://vitejs.dev/config/
// // Change to the name of your repository
// // According to https://vitejs.dev/guide/static-deploy.html
// base: '/webgis-class-2024-g7/',
// publicDir: "public",
// // Options for the build command
// build: {
// // The name of the folder to which the build is stored.
// // As the folder that github pages expects is /docs, we export to /docs folder.
// outDir: 'docs',
// // This builds the dependencies and bundles using the different imports from the pages.
// // It uses index.html as the main entrypoint.
// // Also adds every html file inside the /pages folder.
// // Further pages must be added to the configuration accordingly.
// rollupOptions: {
// input: {
// main: 'index.html',
// ...Object.fromEntries(
// globSync('pages/*.html').map(file => [// // This remove `pages/` as well as the file extension from each
// // file, so e.g. src/nested/foo.js becomes nested/foo
// path.relative(
// 'pages',
// file.slice(0, file.length - path.extname(file).length)
// ),
// // This expands the relative paths to absolute paths, so e.g.
// // src/nested/foo becomes /project/src/nested/foo.js
// fileURLToPath(new URL(file, import.meta.url))
// ])
// ),
// },
// },
// }
// }
import { globSync } from 'glob';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
// config options
export default defineConfig({
// Complete documentation of Vite configuration on
// https://vitejs.dev/config/
// Change to the name of your repository
// According to https://vitejs.dev/guide/static-deploy.html
base: '/webgis-class-2024-g7/',
publicDir: "public",
// Options for the build command
build: {
// The name of the folder to which the build is stored.
// As the folder that github pages expects is /docs, we export to /docs folder.
outDir: 'docs',
// This builds the dependencies and bundles using the different imports from the pages.
// It uses index.html as the main entrypoint.
// Also adds every html file inside the /pages folder.
// Further pages must be added to the configuration accordingly.
rollupOptions: {
input: {
main: 'index.html',
...Object.fromEntries(
globSync('pages/*.html').map(file => [
// This remove `pages/` as well as the file extension from each
// file, so e.g. src/nested/foo.js becomes nested/foo
path.relative(
'pages',
file.slice(0, file.length - path.extname(file).length)
),
// This expands the relative paths to absolute paths, so e.g.
// src/nested/foo becomes /project/src/nested/foo.js
fileURLToPath(new URL(file, import.meta.url))
])
),
},
},
},
plugins: [
createHtmlPlugin({
minify: true,
inject: {
injectData: {
base: '/webgis-class-2024-g7/'
}
}
})
]
});