Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Different alias resolving based on Entry point (Multi-App/Account setup) #20985

Unanswered
trumko asked this question in Q&A
Discussion options

Hi all,

I'm migrating our app from Webpack to Vite and have run into a challenge with alias resolution.

Our project consists of more than 10 entry points (essentially, different apps that share some core functionality). Each entry point needs to resolve certain aliases differently. For example, the account alias should point to a different directory depending on which app is being built or served (depending on entry point).

With Webpack, we could handle this by dynamically generating the config and serving all entry points from a single dev server. In Vite, the config is static per process, and it seems aliases are resolved globally at server startup, not per entry point.

Is it possible in Vite to resolve an alias like this based on the entry point?

resolve: {
 alias: {
 `account`: path.resolve(__dirname, 'src/apps/app1'), // Ideally, 'app1' would be dynamic, depending on the entry point
 },
},

For example:
For entry point 1, import abc from 'account/some/folder'; should resolve to src/apps/app1/some/folder
For entry point 2, the same import should resolve to src/apps/app2/some/folder

Key requirements:

  • Each entry point (account) should have its own alias resolution for org.
  • Ideally, we’d like to run multiple entry points in parallel for local development (as we did with Webpack).
  • We want to avoid running 10+ separate Vite dev servers if possible, due to resource and workflow concerns.

Is there a recommended way to achieve per-entry-point alias resolution in Vite? Or any best practices for multi-app setups like this?

Thanks in advance!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /