question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not updating modified timestamp of output when working with @import

See original GitHub issue

gulp-sass does not seem to update the modified date of the generated .css file, instead it uses the same date as the input .scss file.

This leads to problems when using gulp-sass together with rails/sprockets. If I update .scss files that are imported into a global.scss, the created css file will still use the same modified timestamp as the global.scss and sprockets will not load the new file.

In order to fix this, I had to manually update the modified time after gulp-sass:

var touch = require('gulp-touch-cmd');

return gulp.src(config.src)
    .pipe(sass(config.settings))
    .pipe(gulp.dest(config.dest))
    .pipe(touch())  /* fix to update modified time */

Tested with versions 2.0.4 and 4.0.1. Gulp 4.0.0

I’m not sure if this is a problem of gulp-sass or gulp itself.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
WraithKennycommented, Sep 13, 2018

In the meantime, if anyone needs the output file to have an updated modified/accessed time, you can pipe this before the gulp.dest pipe (requires you add through2)

.pipe( through2.obj( function( file, enc, cb ) {
	var date = new Date();
	file.stat.atime = date;
	file.stat.mtime = date;
	cb( null, file );
}) )
.pipe( gulp.dest( './' ) )
4reactions
WraithKennycommented, Sep 13, 2018

I hope you reconsider.

This plugin is responsible for the compiled css file, and that file that is compiled from it is reporting the wrong modified time. It’s a bug.

https://github.com/dlmanning/gulp-sass/blob/master/index.js#L99 When you are assigning file.contents and file.path, you should just set file.mtime = new Date(); or some such.

EDIT: file.stat.mtime = new Date();

Read more comments on GitHub >

github_iconTop Results From Across the Web

File modified timestamp not updating... - TechNet - Microsoft
Our business application generates a log file every minute but the issue is the datemodified timestamp is not gets updated automatically.
Read more >
Timestamp in MySQL not updating despite updating records
The main reason that your timestamp is not updating beacuse you have not added ON UPDATE CURRENT_TIMESTAMP clause in your table creation statement....
Read more >
python timestamp doesn't update - Ask Ubuntu
ctime() is not changing when executing my program each 5 second. How can I fix it? My program: import random import time n...
Read more >
File last modified date not updating for certain file types
Through testing I found the issue is different for different file types. The test was simply to rewrite each file to contain only...
Read more >
Column INSERT/UPDATE Defaults
That is, if a table has a column called “timestamp”, and an INSERT statement proceeds which does not include a value for this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found