asset-rack icon indicating copy to clipboard operation
asset-rack copied to clipboard

BrowserifyAsset watch is not working

Open dankohn opened this issue 11 years ago • 6 comments

I'm thrilled with asset-rack and getting fantastic results with StaticAssets and StylusAssets. However, watch: true is not working for BrowserifyAssets, even though it works correctly with StylusAssets. debug: true correctly gives me source maps with browserify, so I know options are being passed correctly.

I was previously using browserify-middleware https://github.com/ForbesLindesay/browserify-middleware , which correctly recompiled the browserify bundle on any change. I'm trying to get asset-rack to do the same. Using nodemon to reload my server is far slower than browserify-middleware was.

Thanks in advance for your help.

dankohn avatar Jun 19 '13 21:06 dankohn

I'm going to have to dig into this. I want to say that I ran into some watch issues a few days ago, so I think there is probably a bug in the implementation.

Just out of curiousity what platform are you on, Mac, Linux, Windows? The fs.watch command which is what it is based on, has some cross platform issues.

techpines avatar Jun 21 '13 18:06 techpines

Mac. I'd be happy to test on Windows or Linux for you if that would be helpful.

dankohn avatar Jun 21 '13 18:06 dankohn

Yea, that would be awesome. I'd really like to get this watch functionality nailed, because I've also been working on another project, http://bone.io which is a Realtime HTML5 framework.

Basically, I want to do live reloading of css stylesheets, and I've built a basic proof of concept with asset-rack and bone.io, but there needs to be some improvements in the asset-rack watch implementation for it to work seamlessly.

I'm also wanting to improve the experience when an asset-rack throws an error. Since it's already hooked up as middleware, I want to get asset-rack to display an HTML error message kind of like express rather than crashing the server. I'd also like to take over the url, "/asset-rack" to display a page with a list of all of the assets that asset-rack has compiled.

I know I'm going off on a tangent here, but I just want to keep in mind some of the other features that I want to add before I go in and fix/refactor the watch code.

techpines avatar Jun 21 '13 19:06 techpines

I love the /asset-rack concept. That would be a huge help during debugging. One other question. I'm an enormous fan of asset-rack, but I don't feel like the first few paragraphs of your Readme explain what it does in a compelling way. Would you be open to a pull request on your Readme that added a new introduction based more on the wording from http://guides.rubyonrails.org/asset_pipeline.html ?

dankohn avatar Jun 21 '13 19:06 dankohn

I'm open to it!

techpines avatar Jun 21 '13 19:06 techpines

Just an update that watch works correctly for Stylus, but is broken for both Browserify and for Static assets. If I add an image to my public directory when watch: true, I need to restart nodemon to have it served out.

dankohn avatar Jun 27 '13 14:06 dankohn