S
S
Sergey2018-04-17 19:04:41
JavaScript
Sergey, 2018-04-17 19:04:41

Versioning in GULP?

I want to version css and js files in order to combat caching, I try to do it throughgulp-replace

gulp.task('version', function(){
  gulp.src(['src/**/*.html','src/**/*.php'])
    .pipe(replace('{{version}}', Date.now() ))
    .pipe(gulp.dest('dist/'));
});

<link rel="stylesheet" href="assets/css/style.css?{{version}}">

But when I try to start the server, I get an error
The following tasks did not complete: dev, build, version
 Did you forget to signal async completion?

What am I doing wrong?) Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eternalSt, 2018-04-17
@1Sergey1

Good day!
Here is one solution to this problem

gulp.task('version', function(){
  return gulp.src(['src/**/*.html','src/**/*.php']) // Добавлен return
    .pipe(replace('{{version}}', Date.now() ))
    .pipe(gulp.dest('dist/'));
});

Now this function will return a stream.
I do not want to rewrite what has already been said by other people and more than once. Therefore, I will give references for studying the issue.
Off dock with a description of the mechanism for gulp 3.9.1 for gulp
4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question