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

Changes to vite.config.js build --watch mode is not reflected as mentioned in the docs #11916

Open
shirotech opened this issue Feb 2, 2023 · 6 comments · May be fixed by #11962
Open

Changes to vite.config.js build --watch mode is not reflected as mentioned in the docs #11916

shirotech opened this issue Feb 2, 2023 · 6 comments · May be fixed by #11962
Labels
contribution welcome documentation Improvements or additions to documentation

Comments

@shirotech
Copy link

Describe the bug

https://vitejs.dev/guide/build.html#rebuild-on-files-changes

With the --watch flag enabled, changes to the vite.config.js, as well as any files to be bundled, will trigger a rebuild.

The above statement is not the case, currently it only works on serve mode and not build mode.

Reproduction

https://stackblitz.com/edit/vitejs-vite-xqrbrg?file=vite.config.js&terminal=dev

Steps to reproduce

Make any changes to let count in vite.config.js, it doesn't work, but running in serve mode via vite command works fine.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vite: ^4.1.1 => 4.1.1


### Used Package Manager

npm

### Logs

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@fi3ework
Copy link
Member

fi3ework commented Feb 6, 2023

build.watch could not watch the config file now since rollup cannot watch a file outside the module graph. The documentation is misleading. We could either make the watch work or correct the doc. I'd like to develop a PR to implement the watch these days.

@shirotech
Copy link
Author

build.watch could not watch the config file now since rollup cannot watch a file outside the module graph. The documentation is misleading. We could either make the watch work or correct the doc. I'd like to develop a PR to implement the watch these days.

It seems include is kind of like a whitelist rather, I thought this.addWatchFile is for adding additional files?

@fi3ework
Copy link
Member

fi3ework commented Feb 7, 2023

I thought this.addWatchFile is for adding additional files?

It might work, but when the config file is changed, we need to start a new rollup watcher with the new rollup config which might be changed. So we need to restart the build function, not only to adding a watched file to rollup.

@fi3ework fi3ework linked a pull request Feb 7, 2023 that will close this issue
9 tasks
@bluwy
Copy link
Member

bluwy commented Nov 12, 2023

Since fixing this is a bit hard without changing the function return signature, let's fix the documentation for now.

@bluwy bluwy added documentation Improvements or additions to documentation contribution welcome and removed pending triage labels Nov 12, 2023
@DamChtlv
Copy link

So if i understand this correctly: vite build --watch doesn't detect newly appended files but vite dev does?
I can also reproduce and quite sad that this doesn't work :/

@naumanahmed19
Copy link

Just tested we still have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants