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

Gulp 4 and mtime on output css file #301

Open
WraithKenny opened this issue Sep 12, 2018 · 3 comments
Open

Gulp 4 and mtime on output css file #301

WraithKenny opened this issue Sep 12, 2018 · 3 comments

Comments

@WraithKenny
Copy link

Gulp 4 intentionally avoids updating the mtime of output files, as a "new feature."

As per gulpjs/gulp#2193 (comment) gulp-less should deliberately update the mtime of the output css file itself, else the file will always retain it's old mtime (for example, my compiled css file, which I've changed today, still says last updated aug 24th).

@WraithKenny
Copy link
Author

A workaround in the meantime is

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

(This is what I used to test... I didn't actually compile gulp-less and really test.)

@bingnz
Copy link

bingnz commented Sep 15, 2018

👍 This change in gulp 4 breaks plugins such as gulp-less-changed, gulp-newer, et al. that rely on the output file times for incremental build optimisation.

bingnz added a commit to bingnz/gulp-less that referenced this issue Sep 17, 2018
bingnz added a commit to bingnz/gulp-less that referenced this issue Sep 17, 2018
bingnz added a commit to bingnz/gulp-less that referenced this issue Sep 18, 2018
@seoMattH
Copy link

seoMattH commented Feb 23, 2019

I am attempting to utilize the work around solution because it is hosing up my ability to add versioning to css files. I understand that this has nothing to do with LESS but any help would be appreciated. I would like to add the pipe that WraithKenny started above:

.pipe( through2.obj( function( file, enc, cb ) {
var date = new Date();
file.stat.atime = date;
file.stat.mtime = date;
cb( null, file );
}) )

How can I add that pipe to work with the following function

function cssversion () {
return gulp.src("_cms/templates/layouts/headBotto*.php")
.pipe(versionNumber({
append: {
'to': [
{'type': 'css',
attr : ['href'],
key : '_v',
value: '%DT%',
'cover' : 1
}
]
}
}))
.pipe(through2.obj( function( file, enc, cb ) {
let date = new Date();
file.stat.atime = date;
file.stat.mtime = date;
cb( null, file );
}) )

.pipe(gulp.dest("_cms/templates/layouts/"));
}

FYI, this new "feature" is really annoying

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