-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
21 lines (17 loc) · 1.22 KB
/
Copy pathbuild.js
File metadata and controls
21 lines (17 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const fs = require('fs');
const path = require('path');
// Read the config template
const configPath = path.join(__dirname, 'public', 'config.js');
let configContent = fs.readFileSync(configPath, 'utf8');
// Replace placeholders with environment variables
configContent = configContent
.replace(`apiKey: '', // Will be replaced at build time`, `apiKey: '${process.env.GOOGLE_CLOUD_API_KEY || ''}',`)
.replace(`apiKey: '', // Will be replaced at build time`, `apiKey: '${process.env.GOOGLE_TRANSLATION_API_KEY || ''}',`)
.replace(`apiKey: '', // Will be replaced at build time`, `apiKey: '${process.env.GOOGLE_TTS_API_KEY || ''}',`)
.replace(`apiKey: '', // Will be replaced at build time`, `apiKey: '${process.env.GOOGLE_CUSTOM_SEARCH_API_KEY || ''}',`)
.replace(`searchEngineId: '' // Will be replaced at build time`, `searchEngineId: '${process.env.GOOGLE_CUSTOM_SEARCH_ENGINE_ID || ''}'`)
.replace(`environment: 'production',`, `environment: '${process.env.NODE_ENV || 'production'}',`)
.replace(`debug: false`, `debug: ${process.env.NODE_ENV === 'development'}`);
// Write the updated config file
fs.writeFileSync(configPath, configContent, 'utf8');
console.log('Config file updated with environment variables');