Skip to content

Commit a0171d9

Browse files
committed
- Web editor texture assets fixes.
1 parent baf4114 commit a0171d9

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

web-editor/vite.config.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import {defineConfig} from 'vite';
1+
import {defineConfig, type Plugin} from 'vite';
22
import react from '@vitejs/plugin-react';
3+
// NOTE: These are Node.js built-ins used by Vite config.
4+
// If your editor reports "Cannot find module 'node:fs'" etc, the root cause is usually missing @types/node.
5+
// Recommended fix (project-wide): add devDependency "@types/node".
6+
// This file keeps local ts-ignore to avoid hard-failing typecheck in environments without node types.
7+
// @ts-ignore
38
import fs from 'node:fs';
9+
// @ts-ignore
410
import path from 'node:path';
11+
// @ts-ignore
512
import {fileURLToPath} from 'node:url';
613

714
type PmAssetIndex = {
@@ -45,6 +52,8 @@ function pmTexturesPlugin() {
4552
const pmLogoFile = path.resolve(__dirname, '..', 'src', 'main', 'resources', 'assets', 'prototypemachinery', 'logo.png');
4653
const includeDirs = [
4754
path.join(pmTexturesRoot, 'gui', 'jei_recipeicons'),
55+
// Machine UI gui_states skins (buttons/toggles/sliders/input boxes, etc)
56+
path.join(pmTexturesRoot, 'gui', 'gui_states'),
4857
];
4958
const includeFiles = [
5059
path.join(pmTexturesRoot, 'gui', 'slot.png'),
@@ -84,9 +93,9 @@ function pmTexturesPlugin() {
8493
return abs;
8594
};
8695

87-
return {
96+
const plugin = {
8897
name: 'pm-textures',
89-
apply: 'serve',
98+
apply: 'serve' as const,
9099
configureServer(server: any) {
91100
server.middlewares.use((req: any, res: any, next: any) => {
92101
const url = req.url || '';
@@ -124,7 +133,9 @@ function pmTexturesPlugin() {
124133
next();
125134
});
126135
},
127-
};
136+
} satisfies Plugin;
137+
138+
return plugin;
128139
}
129140

130141
function pmTexturesBuildPlugin() {
@@ -134,6 +145,8 @@ function pmTexturesBuildPlugin() {
134145
const pmLogoFile = path.resolve(__dirname, '..', 'src', 'main', 'resources', 'assets', 'prototypemachinery', 'logo.png');
135146
const includeDirs = [
136147
path.join(pmTexturesRoot, 'gui', 'jei_recipeicons'),
148+
// Machine UI gui_states skins (buttons/toggles/sliders/input boxes, etc)
149+
path.join(pmTexturesRoot, 'gui', 'gui_states'),
137150
];
138151
const includeFiles = [
139152
path.join(pmTexturesRoot, 'gui', 'slot.png'),
@@ -160,9 +173,9 @@ function pmTexturesBuildPlugin() {
160173
return { paths };
161174
};
162175

163-
return {
176+
const plugin = {
164177
name: 'pm-textures-build',
165-
apply: 'build',
178+
apply: 'build' as const,
166179
generateBundle(this: any) {
167180
const index = computeIndex();
168181

@@ -202,7 +215,9 @@ function pmTexturesBuildPlugin() {
202215
}
203216
}
204217
},
205-
};
218+
} satisfies Plugin;
219+
220+
return plugin;
206221
}
207222

208223
// GitHub Pages 友好:使用相对 base,避免仓库名/子路径问题。

0 commit comments

Comments
 (0)