S
S
Sergey Erin2021-05-27 12:20:35
JavaScript
Sergey Erin, 2021-05-27 12:20:35

Is it possible to update the style file path in the header using gulp?

Good day! I use gulp in development, I created the following task to minify styles:

const	gulp                 = require('gulp'),
    concat 		 = require('gulp-concat'),
    rename 		 = require('gulp-rename'),
    browserSync     = require('browser-sync'),
    cleancss            = require('gulp-clean-css'),
    rev     	          = require('gulp-rev'),
    autoprefixer      = require('gulp-autoprefixer');

gulp.task('minify-css', () => {
  return gulp.src([
    'view/css/main.css',
    'view/css/responsive.css',
  ])
  .pipe(cleancss({ level: { 1: { specialComments: 0, } } } ))
  .pipe(autoprefixer({
    overrideBrowserslist: ['last 10 versions']
  }))
  .pipe(concat('main-styles.min.css'))
  .pipe(rev())
  .pipe(gulp.dest('view/min'))
});


As a result, something like main-styles-47cf597593.min.css is formed.
Tell me, is it possible, after generating a file with a hash, to connect it to the header so that the updated name is not manually written each time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Erin, 2021-05-27
@artalexs

If anyone is interested, used this plugin . There are well described examples of use and options.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question