I'm using gulp and I want to know if it has capabilities for code splitting. Something similar to what is mentioned here in the webpack site . Ive looked online but not seen anything dedicated to that.
Does gulp have code splitting for javascript files?
Asked Answered
Not an appropriate question for SO –
Fradin
You can use webpack from gulp, so if you really want this feature there's nothing stopping you from doing that. –
Matthieu
I feel this is a good question. Was wondering the same thing. +1 –
Dundee
Sir.Nathan Stassen Thanks! –
Malatya
I think this is a great question, personally. I may be wrong (please correct me if I am) but since gulp is a task runner and not a code bundler, I don't think code splitting applies to it. Instead, code splitting would apply to a code bundler like Browserify. WebPack is essentially gulp+browserify+other tools wrapped up in one neat little package. –
Singleminded
I found this on the internet gulp-split-files, I hope this answers your issue.
As you the author has said in the documentation.
In your gulpfile:
const gulp = require("gulp");
const splitFiles = require("gulp-split-files");
gulp.task("split", function () {
return gulp.src("superMegaBigCss.css")
.pipe(splitFiles())
.pipe(gulp.dest("path/to/dest"));
});
This will produce three files:
superMegaBigCss-0.css
superMegaBigCss-1.css
superMegaBigCss-2.css
I don't think this package is very useful, as it split the code where we place the comment /*split*/
.
Personally, I love using webpack so much, now I use it in most of my projects, I think it is like a butcher where it chops down the files and bundles it up in different ways.
© 2022 - 2024 — McMap. All rights reserved.