forked from OpenXE-org/OpenXE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
60 lines (56 loc) · 1.8 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
// SPDX-FileCopyrightText: 2023 Andreas Palm
//
// SPDX-License-Identifier: AGPL-3.0-only
import {globSync} from 'glob';
import * as path from 'path';
import vue from '@vitejs/plugin-vue';
const globpattern = [
'classes/Modules/*/www/js/?(*.)entry.{js,ts}',
'www/themes/*/js/?(*.)entry.{js,ts}'
];
const inputs = globSync(globpattern)
.map(file => {
const regex = /(?<prefix>themes|Modules)\/(?<name>\w+)\/(\w+\/)*((?<entry>\w+)\.)?entry\.(js|ts)$/;
const match = file.match(regex);
console.log(match);
let entryname = file;
if (match) {
entryname = [match.groups.prefix.toLowerCase(), match.groups.name].join('/');
if (match.groups.entry && match.groups.entry.toLowerCase() !== match.groups.name.toLowerCase())
entryname += '-'+match.groups.entry;
}
return [entryname, file];
})
/** @type {import('vite').UserConfig} */
export default {
build: {
rollupOptions: {
input: {
...Object.fromEntries(inputs)
},
output: {
assetFileNames: function(assetInfo) {
console.log(assetInfo);
return 'assets/[name]-[hash][extname]';
},
entryFileNames: function(chunkInfo) {
console.log(chunkInfo);
return '[name]-[hash].js';
},
chunkFileNames: function (chunkInfo) {
console.log(chunkInfo);
return '[name]-[hash].js';
}
}
},
manifest: true,
outDir: 'www/dist',
},
plugins: [vue()],
mode: 'development',
resolve: {
alias: {
'@res': path.resolve(__dirname, 'resources')
}
}
}