V
V
Vlad2021-05-20 12:28:59
JavaScript
Vlad, 2021-05-20 12:28:59

When you have multiple CSS entry points, how do you NOT rebuild all files if only one of them changes?

The project consists of several parts that are independent of each other,
so it is logical to single out several entry points, in particular for css.
There is a task for building css.
How not to rebuild all files if only one of them changes?
And then rebuilding all the files greatly slows down the work.

const path.src.style = ['./assets/src/style/main.scss', './assets/src/style/another-point.scss'],
          path.build.css= './assets/build/css/';
// style build
function css_build () {
    return gulp.src(path.src.style)
        .pipe(plumber())
        .pipe(gulpif(devMode, sourcemaps.init()))
        .pipe(sass())
        .pipe(autoprefixer({
            overrideBrowserslist:  ['last 2 versions'],
            cascade: false
        }))
        .pipe(gulp.dest(path.build.css))
        .pipe(rename({ suffix: '.min' }))
        .pipe(cleanCSS({level: {1: {specialComments: 0}}}))
        .pipe(gulpif(devMode, sourcemaps.write('./'))) 
        .pipe(gulp.dest(path.build.css))
        .pipe(browserSync.reload({ stream: true }));
}
exports.css_build = css_build;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question