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.
It looks like Gulp 4 deliberately does not set mtime anymore, and so the output file now inherits the input file's timestamps (probably purely by historical accident).
It's probably on this library to update the mtime.
Such a feature would belong in a gulp mtime plugin. Gulp Sass is blind to
fs watching. It only cares about compile sass to css
On Thu., 13 Sep. 2018, 4:29 am Ken Newman, notifications@github.com wrote:
It looks like Gulp 4 deliberately does not set mtime anymore, and so the
output file now inherits the input file's timestamps (probably purely by
historical accident).It's probably on this library to update the mtime.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/dlmanning/gulp-sass/issues/706#issuecomment-420751401,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjZWDkDGitQ7QSfUdsOW65E0Docc1drks5uaVKEgaJpZM4WM6B1
.
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();
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( './' ) )
Fixed in v4.1.0
Most helpful comment
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)