D
D
desko2017-02-28 22:02:01
Frontend
desko, 2017-02-28 22:02:01

How to configure Gulp to move files with specific name endings through folders?

What is?
There are images in a specific folder with names ending in *_mdpi.png, *_hdpi.png, *_xhdpi.png, in general resource files for Android mobile developers.
What is needed?
You need images with a specific ending, for example - *_mdpi.png to optimize and move to the drawable-mdpi folder, *_hdpi.png, respectively, to the drawable-hdpi folder, etc.
How to set it up with gulp? I decided to get confused in order to automate the distribution of resources for mobile developers into folders, otherwise now I have to do it all by hand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2017-02-28
@desko

const gulp = require('gulp');
const es = require('event-stream');

gulp.task('move:img', (cb) => {
    let mdpi = gulp.src('./img/**/*_mdpi.png')
        .pipe(gulp.dest('./dist/mdpi'));

    let hdpi = gulp.src('./img/**/*_hdpi.png')
        .pipe(gulp.dest('./dist/hdpi'));

    let xhdpi = gulp.src('./img/**/*_xhdpi.png')
        .pipe(gulp.dest('./dist/xhdpi'));

    return es.concat(mdpi, hdpi, xhdpi);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question