Well, my task is one for example ... how to write something like this at the end of the file /*31.05.2017 20:47:16*/ ?

  gulp.task('js', function() { gulp.src([ 'node_modules/jquery/dist/jquery.js', 'node_modules/bootstrap/dist/js/bootstrap.js', 'src/c-javascripts/owl.carousel.min.js', 'src/c-javascripts/jqstart.js', 'src/c-javascripts/**.js', 'src/c-javascripts/jqend.js' ]) // файлы, которые обрабатываем .pipe(concat('nano.js')) // склеиваем все JS //.pipe(uglify()) // получившуюся "портянку" минифицируем .pipe(gulp.dest('public/js/')) // результат пишем по указанному адресу .pipe(gulp.dest('C:/domains/mysite/js/')) // дубль в сервак }); 

    1 answer 1

    For the name of the file, you can add a piece of code to the file:

     function getDateTime() { var now = new Date(); var year = now.getFullYear(); var month = now.getMonth()+1; var day = now.getDate(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); if(month.toString().length == 1) { var month = '0'+month; } if(day.toString().length == 1) { var day = '0'+day; } if(hour.toString().length == 1) { var hour = '0'+hour; } if(minute.toString().length == 1) { var minute = '0'+minute; } if(second.toString().length == 1) { var second = '0'+second; } var dateTime = year+'-'+month+'-'+day+'T'+hour+':'+minute+':'+second; return dateTime; } 

    And call:

     .pipe(concat('nano.js_' + getDateTime())) 

    And you can add to the file using gulp-insert .

    We need to add some more code:

     var insert = require('gulp-insert'); .... .... .pipe(insert.append('hello_world ' + getDateTime())) 
    • Thanks, great, is it possible to record this date in a div with document.getElementById ("datetime") somehow? - cache0
    • I mean in the output file, if it is html - cache0
    • gulp-dom something doesn't connect - cache0