Initial commit
This commit is contained in:
17
client/scripts/write-env.js
Normal file
17
client/scripts/write-env.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
const rootEnvPath = path.resolve(__dirname, '../../.env');
|
||||
const outputPath = path.resolve(__dirname, '../public/env.js');
|
||||
|
||||
dotenv.config({ path: rootEnvPath });
|
||||
|
||||
const runtimeEnv = {
|
||||
PRIVATECHAT_CLIENT_SERVER_URL: process.env.PRIVATECHAT_CLIENT_SERVER_URL ?? 'http://localhost:3000',
|
||||
};
|
||||
|
||||
const fileContents = `window.__PRIVATECHAT_ENV__ = ${JSON.stringify(runtimeEnv, null, 2)};\n`;
|
||||
|
||||
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
||||
fs.writeFileSync(outputPath, fileContents, 'utf8');
|
||||
Reference in New Issue
Block a user