0
votes

Is it possible to set up grunt task which would run the node.js server (nodemon) and enable livereload on other files (html, js, css, assets)?

I know of several options with grunt-contrib-connect or with grunt-express but none of them works with started node.js server. The problem is that aforementioned packages create its own web server but I just want to connect to my already running node.js server.

I was searching for the solution but I have not found one. Is there some way how to do it? Does somebody have reference to some example?

1
You may consider use of bare cli script execution via npm run seriously it is so much better.dmi3y
@dmi3y does it help to solve the problem?mark
it is rather difficult to say what the problem you are trying to solve, but using cli will help you to separate tasks. Like for example you mentioned you have nodemon, so you will use it only for reloading your node.js server, and using something like live-server for your frontend stack will make things uncoupled. Though yes, you may end up with multiply services running on background, the profit you get from it worth troubles (plus you will unload machine from running task runner).dmi3y

1 Answers

0
votes

You could try requiring your server file and associating it to a custom task:

var Server = require('path/to/server');

grunt.registerTask('server', Server);