update dynamic underpath
This commit is contained in:
21
set-homepage.js
Normal file
21
set-homepage.js
Normal file
@ -0,0 +1,21 @@
|
||||
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`);
|
||||
Reference in New Issue
Block a user