W
W
wakenbyWork2021-08-09 19:08:22
JavaScript
wakenbyWork, 2021-08-09 19:08:22

What is the best way to configure js in gulp?

In general, I'm setting up gulp, and I ran into a misunderstanding of how best to work with npm packages, I found this solution:

const { src, dest } = require('gulp')
const concat = require('gulp-concat')

const files = [
    'node_modules/swiper/swiper-bundle.js',
    'node_modules/animejs/lib/anime.min.js',
    './app/static/scripts/scripts.js'
]

module.exports = function scripts () {
    return src(files)
        .pipe(concat())
        .pipe(dest('dist/js'))
}


That is, all packages are inserted into the js file, is this the norm? Or is it better to create a separate file called libs?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Kulakov, 2021-08-09
@wakenbyWork

If the libs are large (and the swiper is rather big), then it is better to shoot them into a separate vendors.js chunk).
And it's even better to look towards dynamic imports, if there is such a thing in gulp, of course)

F
Froggyweb, 2021-08-10
@Froggyweb

It is better to use webpack for js with gallp
https://vivasart.com/lab/ispolzovanie-webpack-sovm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question