E
E
Evgeny Popov2017-08-22 18:32:44
JavaScript
Evgeny Popov, 2017-08-22 18:32:44

How to set up the assembly of individual js files in gulp, using modules through browserify?

Hello. In gulp, I have my js modules built like this:

gulp.task('js', function(){
    return browserify({
        entries: ['./src/js/script.js']
    })
    .transform(babelify)  
    .bundle()
    .pipe(source('script.min.js'))
    .pipe(buffer()) // <----- convert from streaming to buffered vinyl file object
    .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(uglify())
        .on('error', gutil.log)
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(dirs.build + '/js'));
});

That is, now everything is collected in one script.min.js file. But let's say I don't want to put all js modules in one file, I want to add one more, but I don't understand how. The idea is that only one script was loaded on one page, and another on another page. Who can help implement this in gulp? I hope I explained correctly)

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