Answer the question
In order to leave comments, you need to log in
JS include when building in gulp how to implement?
I’ve been writing a lot of questions lately) I’m building a collector on gulp. Here you need to somehow include js in js files.
So far I have found only this solution https://www.npmjs.com/package/gulp-include
But I would like to generate a sourcemap if possible, maybe there are some other solutions.
It would probably be possible to implement this with the js preprocessor, but I think it’s too early to work in the preprocessor on js )
Answer the question
In order to leave comments, you need to log in
in general, I myself found two options, well, I think this will be enough.
1. gulp-include is the best solution if you are not doing large projects directly or there are some plugins. And you can try gulp-sourcemaps in addition to it, maybe they will also be able to generate maps for whoever needs it. But gulp-include can include not only js, but also any files, even html.
2. gulp-browserify for those who do not want to give up gulp, but there are a lot of pluses here and you can organize modularity. This is for those who work on a large scale.
In general, this solution can help someone.
I use gulp-rigger for this in my projects, it can be useful not only for JS
Use RollupJS. Unlike webpack and browserify, it collects files without any garbage. Unlike gulp include, you can use the import, export es2015 syntax.
If the project is small then use parcel. You write one script in the console and that's it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question