Open max-degterev opened 11 years ago
For me, watch works with Stylus/Jade but not with Browserify or Static. See #79 . Clearly, the watch code needs to be improved. It's only 8 lines of code here: https://github.com/techpines/asset-rack/blob/master/lib/asset.coffee#L108
But, I'm not clear why it's not working.
One possibility would be to import the 3 different watching methods used by nodemon, which is quite reliable for me (just slower to restart): https://github.com/remy/nodemon#help-my-changes-arent-being-detected
I was using nodemon and I don't like to restart server on every filechange as it takes a lot of time. And yes, even for JS/snockets it doesnt look up the dependencies so atm its a totally broken feature
The watch stuff could definitely be improved substantially.
I tried to just make a generic implementation that might work across assets. For some of these compilers like less and stylus, I'm not totally sure how you would figure out the dependency resolution problem unless you hacked into the internals of the library.
One idea might be to put aside trying to understand how each compiler does dependency and file resolution, and allow a user to specify which files to watch, in a more or less flexible format:
toWatch: [
__dirname + '/styles/*.less'
]
I don't know, but I definitely don't like restarting the server, etc.
Yes, don't both trying to understand the dependency graph. Nodemon has a perfectly good model, which is that it supports watching specific extensions in specific directories. The big question is why fs.watch doesn't work.
In my opinion what should be done is having multiple ways to determine what to watch.
fs.watch
is marked unstable
My guess is to use whatever code nodemon
uses with changes if necessary as mentioned above. File watching is difficult, so why reinvent the wheel eh?
PS: Instead of yet another global option perhaps it would be wiser to use watch
to take a list instead of toWatch
?
new SomeAsset
url: '/asset/mcAwesome'
watch: [
'list/of'
'files'
'to/watch'
]
Maybe https://github.com/shama/gaze ?
Would be very nice to have it working! And I mean client side precompiled into a variable frontend templates ofc. Having watch only for javascript is just teasing
This is my setup:
Stylus has loads of imports in app.styl, looks like you don't check for imports changes or something.