@@ -216,3 +216,38 @@ tailwind 4, eslint 9
216216reuse and clean up mpc, opi, rpi scripts // impossible
217217--------
218218decent Astro, ShadCN example https://github.com/shadcnblocks/mainline-astro-template
219+ -------------
220+ load env.js from nginx
221+ {isProd && <script src =" /env.js " />}
222+ ``` yml
223+ nmc-nginx-with-volume :
224+ image : nginx:1.29.1-alpine3.22-slim
225+ container_name : nmc-nginx-with-volume
226+ restart : unless-stopped
227+ volumes :
228+ - ./website:/usr/share/nginx/html
229+ - ./env.js:/usr/share/nginx/html/env.js
230+ - ./nginx/nginx.conf:/etc/nginx/nginx.conf
231+ ` ` `
232+ need to include <script /> wherever i use env vars
233+ must do all in js, not html
234+ ` ` ` html
235+ <!-- Load your runtime env first -->
236+ <script src="/env.js"></script>
237+
238+ <!-- Partytown script -->
239+ <script>
240+ // wait until env.js is loaded
241+ const script = document.createElement("script");
242+ script.defer = true;
243+ script.type = "text/partytown";
244+
245+ // dynamically set attributes from runtime env
246+ script.src = window.__RUNTIME_ENV__.PLAUSIBLE_SCRIPT_URL;
247+ script.dataset.domain = window.__RUNTIME_ENV__.PLAUSIBLE_DOMAIN;
248+
249+ document.head.appendChild(script);
250+ </script>
251+ ```
252+ bash sed replace much better, envsubst instead sed for env vars
253+ custom command: in nginx docker-compose.yml too
0 commit comments