1

Currently, we're using the same code base for two front-end environments that both have different entry points. This allows us to easily share code between the environments. However, we would like to share some code that imports files based on the entry.

For example, say we have the entries 'env1' and 'env2'. In a module we have the following code:

import {someVars} from "./foo/settings.ts"

For 'env2', instead of importing settings.ts, the compiler resolves to the file settings.env2.ts (like how React Native does it), or ./bar/settings.ts.

We have been looking into using a multi-compiler configuration, but that causes issues during development, as we're using webpack serve (webpack-dev-server). We're also looking into creating a plugin that resolves based on the entry, but the entry information does not always seem available per resolve.

What's the best solution for resolving differently per entry?

Maarten
  • 23
  • 4

0 Answers0