You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"_comment": "This RC file demonstrates npm variable interpolation. Variables like $npm_package_version are replaced with values from package.json in the same directory.",
Copy file name to clipboardExpand all lines: CLAUDE.md
+89Lines changed: 89 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,3 +310,92 @@ The generated header file includes a `//config:` comment at the top that display
310
310
- Shows all configuration parameters: `engine`, `sourcepath`, `outputfile`, `etag`, `gzip`, `cachetime`, `espmethod`, `define`, and `exclude` patterns
311
311
- Works consistently whether configuration comes from RC file, CLI arguments, or both
312
312
- Provides complete traceability of the configuration used for code generation
313
+
314
+
## NPM Package Variable Interpolation
315
+
316
+
RC files support automatic variable interpolation from `package.json`, allowing dynamic configuration based on project metadata.
317
+
318
+
**Feature:** Variables like `$npm_package_version` and `$npm_package_name` in RC files are automatically replaced with values from `package.json` located in the same directory as the RC file.
319
+
320
+
**Supported Fields:** All string fields in RC configuration:
Copy file name to clipboardExpand all lines: README.md
+85Lines changed: 85 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ In order to be able to easily update OTA, it is important - from the users' poin
12
12
13
13
This npm package provides a solution for **inserting any JS client application into the ESP web server** (PsychicHttp and also ESPAsyncWebServer (https://github.com/ESP32Async/ESPAsyncWebServer) and ESP-IDF available, PsychicHttp is the default). For this, JS, html, css, font, assets, etc. files must be converted to binary byte array. Npm mode is easy to use and easy to **integrate into your CI/CD pipeline**.
14
14
15
+
> Starting with version v1.13.0, RC files support npm package variable interpolation
16
+
15
17
> Starting with version v1.12.0, you can use RC file for configuration
16
18
17
19
> Starting with version v1.11.0, you can exclude files by pattern
@@ -540,6 +542,89 @@ To keep defaults, explicitly list them in your RC file:
540
542
}
541
543
```
542
544
545
+
#### NPM Package Variable Interpolation
546
+
547
+
RC files support automatic variable interpolation from your `package.json`. This allows you to reference package.json fields in your RC configuration using npm-style variable syntax.
-`package.json` must exist in the same directory as the RC file
619
+
- If variables are used but `package.json` is not found, an error is thrown with details about which fields contain variables
620
+
- Unknown variables are left unchanged (e.g., `$npm_package_nonexistent` stays as-is)
621
+
622
+
**Use Cases:**
623
+
624
+
-**Version Synchronization:** Keep header version in sync with npm package version
625
+
-**Dynamic Naming:** Use package name for C++ defines automatically
626
+
-**CI/CD Integration:** Reusable RC files across projects with different package names
627
+
543
628
### Q&A
544
629
545
630
-**How big a frontend application can be placed?** If you compress the content with gzip, even a 3-4Mb assets directory can be placed. This is a serious enough amount to serve a complete application.
0 commit comments