tugberkugurlu / gulp-dnx

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

Start browser sync #25

Open jrock2004 opened 9 years ago

jrock2004 commented 9 years ago

I want to be able to start browser-sync after my dnx server starts. Does this plugin support a callback or an identifier in the code to say its started the server?

tugberkugurlu commented 9 years ago

IIRC, @luisrudge got this working with browser-sync together a while back, right?

luisrudge commented 9 years ago

Yes! Look here: https://github.com/luisrudge/generator-simple-aspnet/blob/master/app/templates/src/gulpfile.js

zhouhao27 commented 9 years ago

Got an error message:

gulp.task('aspnet', ['build-client'], aspnet(opts.server.aspnet)); ^ TypeError: undefined is not a function

What is aspnet?

luisrudge commented 9 years ago

Can you copy your gulp file here?

zhouhao27 commented 8 years ago

I just copied your gulp file.

luisrudge commented 8 years ago

did you run npm install?

zhouhao27 commented 8 years ago

Yes. I installed.

luisrudge commented 8 years ago

can you put a repro up on github? or at least show me both your packages.json and gulpfile.js files

amcdnl commented 8 years ago

@luisrudge heres my config:

var gulp = require('gulp');
var browserSync = require('browser-sync');
var proxyMiddleware = require('http-proxy-middleware');
var historyApiFallback = require('connect-history-api-fallback');
var path = require('path');
var dnx = require('gulp-dnx');

gulp.task('start', ['web', 'api']);

gulp.task('web', function(done){
  var apiProxy = proxyMiddleware('/api', { 
    target: options.baseUrl,
    ws: true,
    changeOrigin: true
  });

  browserSync({
    files: ['wwwroot/index.html'],
    server: {
      baseDir: ['wwwroot'],
      middleware: [ apiProxy, historyApiFallback() ]
    }
  }, done);
});

var options = {
  cwd: path.resolve(path.join(__dirname, '..', '..', 'API')),
  baseUrl: 'http://localhost:5000/',
  restore: false,
  build: false,
  run: true
};

gulp.task('api', dnx('web', options));

however, it has an issue stated here: https://github.com/aspnet/KestrelHttpServer/issues/636