D
D
Denoro552018-09-21 04:22:37
Node.js
Denoro55, 2018-09-21 04:22:37

How to do reload in express Node.js using Gulp?

var express = require("express");
var app = express();
app.get("/", function(request, response){
    response.send("<h2>Привет Express!</h2>");
});
app.listen(3000);

Let's say I'm running the server on express on port 3000
How do I properly configure gulp so that it listens for changes in pug, scss? After all, it also runs on some port.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Kudryavtsev, 2018-09-21
@Deissh

Example, change for yourself.

...
const exec = require('child_process').exec;
...
const paths = {
    allSrcJs: 'src/**/*.js',
    libDir: 'lib',
};
gulp.task('main', gulp.series('build', (callback) => {
    exec(`node ${paths.libDir}`, (error, stdout) => {
        console.log(stdout);
        return callback(error);
    });
}));

gulp.task('watch', () => {
    gulp.watch(paths.allSrcJs, ['main']);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question