question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FR] Add resolve.modules for relocating the source tree

See original GitHub issue

Clear 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
khalwatcommented, May 15, 2021

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:

    "@rollup/plugin-node-resolve": "^13.0.0",

…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

2reactions
Niputicommented, May 15, 2021

it looks like he found solution for what he wanted to do https://discord.com/channels/804011606160703521/804440129095073893/842934328136171530

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found