22 lines
650 B
JavaScript
22 lines
650 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const dotenv = require('dotenv');
|
|
|
|
// Load environment variables from .env
|
|
dotenv.config();
|
|
|
|
// Get the REACT_APP_BASE_URL from .env
|
|
const baseUrl = process.env.REACT_APP_BASE_URL || '/';
|
|
|
|
// Read the package.json file
|
|
const packageJsonPath = path.join(__dirname, 'package.json');
|
|
const packageJson = require(packageJsonPath);
|
|
|
|
// Update the homepage field in package.json
|
|
packageJson.homepage = baseUrl;
|
|
|
|
// Write the updated package.json back to the file
|
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
|
|
console.log(`Updated homepage to ${baseUrl} in package.json`);
|