Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not updating modified timestamp of output when working with @import #706

Closed
Fulanko opened this issue Aug 26, 2018 · 6 comments
Closed

Not updating modified timestamp of output when working with @import #706

Fulanko opened this issue Aug 26, 2018 · 6 comments

Comments

@Fulanko
Copy link

Fulanko commented Aug 26, 2018

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.

@WraithKenny
Copy link
Contributor

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.

@xzyfer
Copy link
Collaborator

xzyfer commented Sep 12, 2018 via email

@xzyfer xzyfer closed this as completed Sep 12, 2018
@WraithKenny
Copy link
Contributor

WraithKenny commented 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();

@WraithKenny
Copy link
Contributor

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( './' ) )

@WraithKenny
Copy link
Contributor

gulpjs/gulp#2193 (comment)

@xzyfer
Copy link
Collaborator

xzyfer commented Apr 23, 2020

Fixed in v4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants