@twoday/env-public-config-and-messages-scripts
v0.1.1
Published
Build environment specific messages and `.env.json` files.
Downloads
1
Readme
@twoday/env-public-config-and-messages-scripts
Build environment specific messages and .env.json
files.
Usage
Add
.gitignore
:# translations /.aggregated-lang # generated /src/.env-manifest.json /public/.env
Add
package.json
"scripts"
:"predev": "npm run env-manifest", // Vite "prestart": "npm run env-manifest", // CRA "prebuild": "npm run env-manifest", "env-manifest": "env-public-config-and-messages-scripts",
Add translations and
ENV
configsBased on message files in
/.aggregated-lang
it is possible to add specific messages for different environments. It is also possible to add.env.json
files for different environments.⚠️ The contents of the messages and
.env.json
files are public. Do not place any secrets in them./environments /example.com /.env.json /en-US.json /en.json /favicon.png /fi-FI.json /test.example.com /.env.json /en.json /favicon.png /fi-FI.json
Load correct
.env.json
for the environment// main.js import { getFilePath } from "@twoday/env-public-config-and-messages"; import envManifest from "./.env-manifest.json"; // ... const envPath = getFilePath(envManifest, [({ type }) => type === "env"]); if (envPath) { await loadRuntimeConfig(`${ENV.BASENAME ?? ""}/${envPath}`); } // console.log(ENV); // ...
Use
<IntlProvider>
from@twoday/react-intl-bundled-messages