tugberkugurlu / gulp-dnx

Gulp plugin for ASP.NET 5
MIT License
38 stars 14 forks source link

Add dnx-watch comand #26

Closed Codenator81 closed 8 years ago

Codenator81 commented 8 years ago

ASP.NET have now nice dnx-watch comand wich reload server when files changed. It will be great if gulp-dnx have that comand out of box. Thanks

luisrudge commented 8 years ago

the problem is that dnx-watch has to be added by the user (dnu commands install Microsoft.Dnx.Watcher). How can we know if the command is available or not?

Codenator81 commented 8 years ago

aspnet/dnx-watch#27

luisrudge commented 8 years ago

Awesome.. I'll subscribe to that

jasoncavett commented 8 years ago

With the other issue Closed, is there any chance this one will be completed? My guess is you may be seeing a lot of traffic this way due to Scott Hanselman's post of integrating Visual Studio Code and dnx commands.

luisrudge commented 8 years ago

Why you want dnx-watch if you can just use gulp to kill and restart? It's not like dnx-watch is bringing anything new to the table.

jasoncavett commented 8 years ago

@luisrudge Maybe I'm misunderstanding, but I was under the impression that dnx-watch will watch for file changes and automatically restart the server. (I have also used gulp to this ends, but, following Scott's post that I referenced above allowed me to do away with a bunch of gulp scripting to make that work properly.) Granted, there is the issue of the minification of JS/CSS and the compiling of SCSS that is not part of dnx-watch, but I just run another task that handles that.

If I have an incorrect understanding of the toolchain, I'm happy to learn the best way to use it.

Codenator81 commented 8 years ago

I using nodemon for watching everything. For example

nodemon --ignore htm,html --ext cs,js --exec "dnx web" -V
luisrudge commented 8 years ago

@Codenator81 it makes no sense to restart the entire dnx app if a .js file changes.. Well.. not in the majority of the cases anyway.

luisrudge commented 8 years ago

@jasoncavett dnx-watch is good if you're not using a task runner. If you're, your're better off using the task runner to do this.

Simple example:

gulp.task('dnx', dnx('kestrel'));
gulp.task('default', function() {
  gulp.watch('./**/*.cs', ['dnx']);
});

Complete example (a little out of date): https://github.com/luisrudge/generator-simple-aspnet/blob/master/app/templates/src/gulpfile.js

amcdnl commented 8 years ago

@luisrudge Is there any performance trade off doing the gulp-watch instead of this?

luisrudge commented 8 years ago

I don't think so.. Both are processes that watch some files and, when at least one of the file changes, kill the process and start again.

amcdnl commented 8 years ago

Cool, wasn't sure if they were doing something efficient under the hood since that have core lib access.

luisrudge commented 8 years ago

If anything, gulp allows you to pick and choose what files will be watched, so I guess it's a little more flexible

amcdnl commented 8 years ago

Yup, thats more the 'gulp' way anyways.

qbikez commented 8 years ago

Actually, dnx-watch analyzes project.json structure and watches any files that are included in the project, as well as all referenced projects and their files. So it may be more convenient to use for larger projects. Besides, you already use dnx --watch, so maybe just replace that with plain dnx to avoid confusion?

luisrudge commented 8 years ago

@qbikez you don't need to restart when a js, css, cshtml file changes... Gulp, in that way, is better at this because you can pick and choose.

amcdnl commented 8 years ago

@qbikez I actually ended up building my own plugin for dnx, check it out here: https://github.com/Swimlane/gulp-aspnet5 ( sorry not trying to troll, just help him out )