Answer the question
In order to leave comments, you need to log in
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'))
}
Answer the question
In order to leave comments, you need to log in
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)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question