Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
How to edit a JSON file of a React production build

In my developer build I have a JSON file with one data, I want to be able to change that data in the production build. I used npm run build to make the build. And I can't find that JSON file. I'm making this website for someone so I want to make it easy to change the page content by using JSON.

// src/json/download.json
{
    "file" :  "download.png"
}
This is how I get the json file
const file = require("../json/download.json").file

const filePath = "download/" + file;

const Nav = () => {
    return (
        <Link className="dcm0cujv48 abled" to={filePath} target="_blank" download={file}>
            <p className="fs-14 fw-700 wspwho0gps">
                <i class="fas fa-cloud-download-alt fs-14"></i>
                Download
            </p>
            <p className="yb08fmpwlp"></p>
        </Link>
    )
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can check if you are in developement or production

function isProduction(){
return process.env.NODE_ENV === "production"
}

then in your code

const filePath = "download/" + isProduction() ? pathToProductionFile : pathToLocalFile;

then in your scripts you need to create another build scripts with the flag "NODE_ENV=production"

Or setup multiple .env files, check out https://www.npmjs.com/package/dotenv for example .env.local

file=download.png

and .env.production

file=production-download.png

then in your code you can use

process.env.file 

as a variable that holds the value of your file and will differ from local to production

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda