Wednesday, 3 May 2017

Livereload reloads only the first .css file in head

I am setting up Livereload in a Node environment, using Express server and Gulp as my task runner and, finally, using Ejs for my templates.

The issue: I am not able to get all .css reloaded. I only get the first .css file in head bound to the livereload server.

Current set up:

I installed livereload package, and set it up in my index.js file like:

// ...
// index.js

var lr = require('livereload');
var lrServer = lr.createServer();
lrServer.watch(__dirname + '/public');

Note: Right now, all my files are in /public folder. Later I will set them up to a /dist folder.

The express set up is a very basic set up.

// ...
// index.js
//
// ================================================
// Ejs for my templates/partials
// ================================================
app.engine('.ejs', require('ejs').__express);
app.set('view engine', 'ejs');

// ================================================    
// static files from my currently set static folder
// ================================================
app.use(express.static(path.join(__dirname + '/public')));

// ================================================    
// Express starting on :3000 + istanbul ignore next
// ================================================
if (!module.parent) {
    var port = 3000;
    app.listen(port);
    console.log('Express started on port', port);
}

Finally, I start my server with nodemon

"#file": "package.json",
...
"scripts": {
    "start": "nodemon -e js,ejs --watch views index.js",
},
...

If everything should be fine, is there an alternative way, without using livereload plugin, to get a Node/Express/Ejs/Gulp environment working with Livereload?

Thank you all for you help.



via caruso_g

No comments:

Post a Comment