[FR] Add resolve.modules for relocating the source tree
See original GitHub issueClear and concise description of the problem
I’d like to be able to locate the source code (aka project root) separately from the buildchain.
In other words, I’d like to move Vite’s project root elsewhere using the root
config option, but keep the package.json
and node_modules
in a separate buildchain directory, like this:
├── buildchain
│ ├── .env
│ ├── node_modules
│ ├── package-lock.json
│ ├── package.json
│ └── vite.config.js
└── assets
├── dist
├── public
│ └── image.png
└── src
├── css
│ └── app.pcss
└── js
└── app.js
In the above diagram, the project root would be: ../assets
You currently can’t do this as far as I can tell, because Vite assumes node_modules
will be in the project root, and imports will fail if it isn’t.
I’d suggest adding a config option like webpack’s resolve.modules
:
https://webpack.js.org/configuration/resolve/#resolvemodules
…which allows you to specify where the node_modules
directory lives for resolving purposes.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Resolve | webpack
Configure how modules are resolved. For example, when calling import 'lodash' in ES2015, the resolve options can change where webpack goes to look...
Read more >Unable to resolve module `react-native-reanimated`
As soon as I added createDrawerNavigator my builds were failing with errors: Unable to resolve module react-native-reanimated.
Read more >DaVinci Resolve 18 – Fusion | Blackmagic Design
To do this, drag a merge node from the toolbar into the node tree. Use the yellow control to connect a background image...
Read more >Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
In this article, we will explore what causes, how to prevent, and how to solve the “fatal: not a git repository” error.
Read more >Frequently Asked Questions — Weblate 4.15.1 documentation
Add and update Weblate remotes git remote add weblate-one ... Resolve conflicts git commit # Push changes to the upstream repository, Weblate will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The cases are when you are integrating Vite into a larger project (CMS, Laravel, whatever).
I have found a config that works (thanks to Jared) using:
…and file system aliases. It still feels a little icky, but it works. I’d love to see something like the webpack resolve.modules config that works globally
it looks like he found solution for what he wanted to do https://discord.com/channels/804011606160703521/804440129095073893/842934328136171530