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

210
Views
Is it possible to do import js differently depending on the build target?

I developed games using unity3d and unrealengine, and this time I developed the web for the first time. I am going to use react, javascript, material-ui, and styled-component with visual studio code and sourcetree for git.

The site I need to develop has a similar basic structure, but I need to create several sites with slightly different detailed functions.

For example, when running for domain aaa.com, component comp is from the file 'src/aaa/compPerTarget/comp', and when running for domain bbb.com, 'src/bbb/compPerTarget/comp' be used. And most important thing is the source where comp is used is not be changed for "import 'compPerTarget/comp'"

Pages using component comp

import Comp from 'compPerTarget/Comp'

...

When build or run source for target aaa.com use 'src/aaa/compPerTarget/comp'

function Comp() {
  const logicForAAA = () => {...};

  return (
    <div>using div..<div>
  );
}

When build or run source for target bbb.com use 'src/bbb/compPerTarget/comp'

function Comp() {
  const logicForBBB = () => {...};

  return (
    <li>using li..<li>
  );
}

I'm trying to solve it using jsonconfig.json and webpack.config.js, but I'm wondering if this is the right way to go, and if there is another way to solve it more easily, please advise me.

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!