forked from fishpondstudio/CivIdle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
52 lines (49 loc) · 1.3 KB
/
vite.config.mts
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
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import Spritesmith from "vite-plugin-spritesmith";
const NO_SPRITE_WATCH = false;
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
return {
base: "",
plugins: [
react(),
buildAtlas("rome", command === "serve"),
buildAtlas("people", command === "serve"),
buildAtlas("buildings", command === "serve"),
buildAtlas("tiles", command === "serve"),
buildAtlas("flags", command === "serve"),
buildAtlas("misc", command === "serve"),
],
server: {
port: 3000,
host: true,
},
build: {
target: "es2015",
},
test: {
browser: {
enabled: true,
headless: true,
name: "chrome",
},
},
};
});
function buildAtlas(folder: string, watch: boolean) {
return Spritesmith({
watch: !NO_SPRITE_WATCH && watch,
src: {
cwd: `./src/textures/${folder}`,
glob: "*.png",
},
target: {
image: `./src/images/textures_${folder}.png`,
css: [[`./src/images/textures_${folder}.json`, { format: "json_texture" }]],
},
spritesmithOptions: {
padding: 1,
},
});
}