I'd like to extend this issue to be in general add support for polling environments.
In addition to webpack there are a couple usages of chokidar and nodemon to build the full the watching environment. I believe all of those locations would need additional options to get a full environment that works where file watchers do not.
Can we enhance Nuxt to allow a simple way for a developer to express that they need polling everywhere?
Why do you need to specify the watchOptions @eimhin?
@corsen2000 I prefer not to add so many options into the nuxt.config.js (it already has a lot...)
Chokidar is pretty easy to use, see how we use it to watch the nuxt.config.js in nuxt dev: https://github.com/nuxt/nuxt.js/blob/master/bin/nuxt-dev#L37-L67
@Atinux I don't understand what you are saying here. Chokidar seems to be used deeply within the various build scripts, for example here. There is no way to pass additional options to it so that it can be configured to poll, which is needed for some development environments where file watchers do not work properly. This is common with ssh development environments or things like Vagrant.
Without adding options, I don't see how a developer could work in these environments.
This is not my preferred environment to work in and I actively suggest that others do not do so, but I have had colleagues ask me about this, which is why I added on to the issue. This may deter some from using this project.
Perhaps I am misunderstanding this limitation?
@corsen2000 could you give me an example of the options you might want to give to chokidar there?
usePolling which can be seen in this documentation. The description of when to use this option from their documentation matches what I've tried to explain here.
Any other file watchers in this system would need to be configured with similar options. For example if Nuxt is using a webpack watcher.
I see @corsen2000
What do you think of a watchers option in nuxt.config.js:
module.exports = {
watchers: {
chokidar: {
usePolling: true,
useFsEvents: false
},
webpack: {
aggregateTimeout: 300,
poll: 1000
}
}
}
@Atinux something like that would certainly allow the developer to provide the needed configuration. Looks like a good solution to me. There are a few other concerns to get this whole process working.
If we want to support developers who work in these environments well we will probably need some solid documentation explaining everything and providing guidance.
I appreciate the continued discussion on this, but do please bare in mind. This is not my preferred environment and my colleagues have switched to avoid this problem, so we do not have an immediate need. @eimhin and others may still be eager to get these configuration options though.
@Atinux I'm developing within a Vagrant box using a shared folder for Nuxt. The HMR and browser refresh provided by Webpack doesn't pick up on file changes within a shared folder. I've tried a few things and so far only polling has worked for me unfortunately so that's why I posted this request. It's not the end of the world if it can't be done but would be a nice to have. :)
The watchers options are now available with the 0.10.3: https://nuxtjs.org/api/configuration-watchers
For nodemon, nuxt/express is only a template so you can configure the nodemon command directly inside.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
The
watchersoptions are now available with the 0.10.3: https://nuxtjs.org/api/configuration-watchersFor nodemon, nuxt/express is only a template so you can configure the nodemon command directly inside.