Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

390
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!