Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

189
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.

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos