Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to change index.html location but keep root #306

Closed
m4rvr opened this issue May 29, 2020 · 1 comment · May be fixed by #16629
Closed

Possibility to change index.html location but keep root #306

m4rvr opened this issue May 29, 2020 · 1 comment · May be fixed by #16629

Comments

@m4rvr
Copy link
Contributor

m4rvr commented May 29, 2020

Is your feature request related to a problem? Please describe.
Currently I can either change root to a subfolder (which doesn't work for all other folders outside) or have root at the root but it needs an index.html in this directory.

Something like a monorepo where I have a /fixture or /playground folder for development but it should also watch all other packages in /packages/. Setting root to /playground works but doesn't include all other files outside.

I know monorepo support is currently a future thing but don't know if it's really a monorepo "problem". Is this even possible or does the root need to be always where the index.html is?

Describe the solution you'd like
Maybe introducing a new option entry/indexEntry to be able to change the location e.g. --entry=./playground/index.html or from the vite.config.ts.

Additional context
Current project structure:

Root
├── packages     <-- but should also watch those
│   ├── package-1
│   └── package-2
└── playground   <-- this is the "dev" environment
     ├── index.html
     ├── App.vue
     └── main.ts
@yyx990803
Copy link
Member

You can do this with the latest alias improvement in 0.18. Assuming you are placing a vite.config.js in project root:

// vite.config.js
module.exports = {
  root: path.resolve(__dirname, 'playground'),
  alias: {
    '/package-1/': path.resolve(__dirname, 'packages/package-1'),
    '/package-2/': path.resolve(__dirname, 'packages/package-2'),
  }
}

I also just pushed 8fe4284 which should make HMR work for files that are aliased but out of root.

Note you need to import aliased files as /package-1/xxx - the leading slash is required, otherwise it's considered a dependency request.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants