A
A
Andreo2018-10-09 16:31:36
JavaScript
Andreo, 2018-10-09 16:31:36

How to include JS script (ES5/6...) using Gulp?

In short, there is a task in gulpfile that collects third-party libraries into one file:

gulp.task('vendor', function() {
    var src = [
        'node_modules/jquery/dist/jquery.min.js',
        'node_modules/lodash/lodash.min.js',
        'node_modules/vue/dist/vue.min.js',
        'node_modules/vue-resource/dist/vue-resource.min.js',
        'node_modules/blockui-npm/jquery.blockUI.js',
        'node_modules/sweetalert/dist/sweetalert.min.js',
        'node_modules/moment/min/moment.min.js',
        'node_modules/sprintf-js/dist/sprintf.min.js',
    ];

    gulp.src(src)
        .pipe(concat('vendor.build.js'))
        .pipe(gulp.dest('public/js'));
});

Thank the gods - I figured it out!
But there was a need to use the library from node_modules, but with all sorts of exports, require and other game of the latest JS syntax ... How to embed such a script in my js file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2018-10-09
@rockon404

Thank the gods - I figured it out!

Don't show it to anyone else.
Either study "all these exports, require and other game", or look for an easier job.
How to build a bundle:
webpack
browserify

K
Konstantin Velichko, 2018-11-02
@Zoxon

Use webpack
An example of how to use webpack with gulp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question