Replies: 1 comment 2 replies
-
Although task() is depreciated as an API, the So for instance in your example of
I'm doing exactly this for two build tasks (
It seems a little redundant, but it works... |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Migrating all my gulp3 stuff to gulp4 (finally, I know).
I understand that using the
task()
api is no longer recommended and the preferred approach is named exports.For simple builds using gulp this is not a big deal. However when using gulp to build an entire website, there are a bunch of parallel/unrelated builds that happen...for instance:
most of these individual builds will have multiple sub-steps that need to be run in some parallel/series combination depending on requirements.
Each of these builds will export
clean
,build
, andwatch
.For cleanliness, I have separated each build into their own gulpfile (e.g.
gulp/javascript.js
for the javascript build).I also include a
gulp/index.js
that just requires/exports each build into a chosen namespace...Then from the main gulpfile.js I can include the sub-builds and nicely reference each. Something like the following...
The problem
is that all the individual build files may internally use function names like
build
,concat
,clean
.In the old days with named
task()
I had a fair bit of flexibility in task naming (arbitrary strings)...although you had to rely on the developer to follow some convention or dynamically register tasks to force some naming convention (e.g. namespacing/prefixing... likejavascript:build
vsstyles:build
).Now it seems like gulp4 always displays the underlying function name?
This makes it quite difficult to differentiate where it is the
styles.build
orjs.build
task that is failing.As an example you can see the following is quite useless. During the actual build process it is the same (watch failed, watch didn't complete, etc...but which one?).
So I am hoping there is some convention or support within gulp4 to override task names (without using
task()
api) or somehow namespace sub tasks so it is more readily obvious what task we are looking at. Given usingtask()
is no longer recommended I don't want to go down that path...so I guess either no one has this particular problem (I'm doing something wrong) or there is an elegant way to address this issue.Of course I could just follow some convention in function naming (within more limited restrictions of valid function names)...for instance every function in the javascript gulpfile could be named with prefix
javascript_
. However that feels pretty clunky.Gulp also apparently ignores the export names and uses the underlying function names...
...so prefixing export naming doesn't help. Even if it did that would only work for stuff that is exported. Gulp also reports on internal sub-tasks that aren't exported and these display the internal function names (e.g.
concat
function within thejavascript.js
file without any context).Very possible that what I am doing is all a big nasty antipattern...but as the docs, google and other discussions/issues don't seem to offer any advice on this particular scenario...I'm hoping it is obvious and I've just completely missed it.
Appreciate any insight or advice you can offer. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions