Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

cli --watch is not working #210

Closed
jasonkuhrt opened this Issue · 8 comments

6 participants

@jasonkuhrt

I am on osx Mountain Lion, node 8.6, macvim

Commands like:

browserify -w -e client.coffee -o public/app.js
browserify client.coffee -o public/app.js -w

Compile successfully, but any subsequent file changes (entry or required files) does not cause a recompile.

Who else is having this issue?

@jasonkuhrt

I am still having this problem with 1.15.5

@Supporting

I have the same problem on Windows with node 0.8.9 and browserify 1.16.1

@substack
Owner

watch is gone in v2 but when it comes back I'd like to have it be a separate module entirely.

@substack substack closed this
@jiyinyiyong

Looking forword to --watch's recurrence.

@jhnns

Meanwhile you could use isaac's supervisor. I use it for compiling less files. I haven't tested the command but you could try something like this:

supervisor -n exit -w -x browserify -- client.coffee -o public/app.js

@jiyinyiyong

@jhnns Since I write CoffeeScript, Stylus and all of them need compiling,
by now I use a Cakefile to compile them(doodle is my personal comamnd)..
Seems Browserify need to watch more than one file which appears in that command.
Does supervisor watch the files required by this one(I'm not familiar about that)?


My Cakefile:

{spawn, exec} = require "child_process"
fs = require "fs"

echo = (child) ->
  child.stderr.pipe process.stderr
  child.stdout.pipe process.stdout

split = (str) -> str.split " "

queue = [
  "jade -O ./ -wP layout/index.jade"
  "coffee -o page/ -wbc action/"
  "stylus -o page/ -w layout/"
  "doodle page/page.css index.html build.js"
]

build = ->
  exec "browserify -d page/main.js", (err, stdout, stderr) ->
    console.log "write.. #{stdout[..40]}"
    fs.writeFile "build.js", stdout, "utf8"

stamp = 0
cache = 0

do watch_loop = ->
  unless cache is stamp
    cache = stamp
    build()
  setTimeout watch_loop, 300

task "dev", "watch and convert files", ->
  queue.map(split).forEach (array) ->
    echo (spawn array[0], array[1..])

  list = fs.readdirSync "page/"
  for name in list
    if name.match /\S+\.js$/
      fs.watch "page/#{name}", interval: 200, ->
        stamp += 1

Quite hope there's an abstraction between CLI and Node which can do that.

@epeli

I've used this dead simple shell script https://gist.github.com/epeli/5233969

./watch.sh browserify foo.js > bundle.js
@jiyinyiyong

@epeli inotifywait is wonderful!

@jiyinyiyong jiyinyiyong referenced this issue in coffee-js/languages
Closed

Browserify + coffeeify 的前端调试方案 #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.