-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
70 lines (68 loc) · 1.81 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
import { defineConfig } from "vite";
import { resolve } from "path";
import { splitVendorChunkPlugin } from "vite";
import glslify from "rollup-plugin-glslify";
const root = "src";
export default defineConfig({
root,
base: "/",
publicDir: "../public",
plugins: [
splitVendorChunkPlugin(),
glslify({
compress(code) {
// Based on https://github.com/vwochnik/rollup-plugin-glsl
// Modified to remove multiline comments. See #16
let needNewline = false;
return code
.replace(
/\\(?:\r\n|\n\r|\n|\r)|\/\*.*?\*\/|\/\/(?:\\(?:\r\n|\n\r|\n|\r)|[^\n\r])*/gs,
""
)
.split(/\n+/)
.reduce((result, line) => {
line = line.trim().replace(/\s{2,}|\t/, " "); // lgtm[js/incomplete-sanitization]
if (line.charAt(0) === "#" || /else/.test(line)) {
if (needNewline) {
result.push("\n");
}
result.push(line, "\n");
needNewline = false;
} else {
result.push(
line.replace(
/\s*({|}|=|\*|,|\+|\/|>|<|&|\||\[|\]|\(|\)|-|!|;)\s*/g,
"$1"
)
);
needNewline = true;
}
return result;
}, [])
.join(process.env.NODE_ENV === "development" ? "\n" : "")
.replace(/\n+/g, "\n");
},
}),
],
resolve: {
alias: [
{
find: "#",
replacement: "/scripts",
},
],
},
build: {
outDir: "../dist",
rollupOptions: {
input: {
// htmlを追加する場合にはこちらに追記
index: resolve(root, "index.html"),
diverse: resolve(root, "diverse.html"),
},
},
},
server: {
host: true,
},
});