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

388
Vistas
Import file in webpack only if file exists in ES6 syntax

Basically, I need to get variable from file, otherwise to get variable from default file.

I see best solution as:

import { variable } from "file.js"; // if variable exists
import { variable } from "default.js"; // otherwise import variable from default

But if file.js not exists I get an error. And its expecting, but not needs for me in this case. Is it possible to fix it with webpack and just ignore this import if file not exists?

An import() statement isn't fit because I need import on build stage, not dynamic import at runtime.

about 4 years ago · Juan Pablo Isaza
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