File size: 1,489 Bytes
61d39e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# utils.js — GUI Build Script (Overview)

This file is responsible for:
- Generating production and development builds of the GUI
- Merging and minifying JS/CSS files
- Converting icon files to base64
- Bundling core GUI logic using Webpack
- Generating the HTML structure dynamically for development mode

## Main Functions

### 🔧 build(options)
Runs the full GUI build process.

**Steps it performs:**
1. Deletes and recreates the `/dist` folder
2. Merges JavaScript libraries → `dist/libs.js`
3. Converts all `src/icons/*.svg/png` to base64 → stores in `window.icons`
4. Merges and minifies CSS → `dist/bundle.min.css`
5. Uses Webpack to bundle `src/index.js` and dependencies → `dist/main.js`
6. Prepends `window.gui_env = "prod"` and writes it as `dist/gui.js`
7. Copies static assets like images, fonts, manifest, etc.

### 🛠️ generateDevHtml(options)
Dynamically builds the HTML string for development mode.

**What it includes:**
- Meta tags (SEO + social)
- CSS & JS includes (based on env)
- Inline base64 image data
- JS entry points for dev (`/index.js`) or prod (`/dist/gui.js`)

---

## Related Files

| File             | Role                                 |
|------------------|---------------------------------------|
| `build.js`       | Just imports and calls `build()`      |
| `BaseConfig.cjs` | Provides Webpack config used in build |
| `static-assets.js` | Lists paths to JS, CSS, icons, etc   |

---