You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need function that remove comment without removing what inside. #3
It would be nice if you could add a function or parameters that remove the "removeIf/endRemoveIf" comments without removing what inside of them.
I use gulp-remove-code to remove some stuff from the minified version of my JS files that I don't want in production, but in the unminified version I keep those thing there, but the "removeIf/endRemoveIf" stay as well.
Would love to be able to keep them but remove the "removeIf/endRemoveIf" comments from the final build.
maybe something like
.pipe(removeCode({ removeCommentsOnly: true }))
@crissdev first, thanks for the module. Any chance of this getting implemented? You mentioned 'next version' back in 2015 and closed #11 last year (the title of which more closely matches what I'm thinking for this issue)
In the meantime, @Sugarcaen / @jfmmm how would you use gulp-strip-comments (or something else?) to only remove the empty/remaining '[rR]emoveIf lines? Seems like there's only an 'ignore' regex option there - no explicit 'remove only matches' option.
I'd love to be able to [at least somewhat] cleanly strip all 'true' removeIf sections as well as specifically the '[rR]emoveIf' comments from all 'false' removeIf sections...
I just want to make sure I'm understanding you, @JoshuaSCochrane, its been a while since I've touched a project using gulp.
You want to pipe something like:
@Sugarcaen precisely, except ideally controlled by an additional option to the gulp removeCode part, like if you have .pipe(removeCode({ production: true }, options.removeInactiveMarkers: true )) (or however you specify options - not quite clear and no examples in the readme). Or perhaps an addition to the markers themselves, something like //removeIf(production, markerEvenIfFalse: true) \ //endRemoveIf(production) so you can control it on a marker-by-marker basis (though I can't imagine why you'd want to keep any inactive markers, maybe someone does)...
I honestly very briefly considered doing something like this (contrived example):
(so it would remove configBThing if config_A but always remove the removeIfs) but then I realized how abysmally ugly that was going to get and may not even work anyway... :p
I also encountered this issue/feature request. I have a feature toggle removeIf(!featureA) which correctly remove the code if the featureA is disabled, but if it's enabled I just want to keep the code without the removeIf comment being there.
The gulp-delete-lines solution sounds good, maybe it could be integrated in the core options as @JoshuaSCochrane mentioned.
Activity
crissdev commentedon Apr 17, 2015
Interesting suggestion. I'll have this implemented for the next version. Thanks.
Sugarcaen commentedon Feb 13, 2017
@jfmmm Couldn't you just use gulp-strip-comments?
jfmmm commentedon Feb 14, 2017
If I had a time machine maybe.
JoshuaSCochrane commentedon Mar 20, 2018
@crissdev first, thanks for the module. Any chance of this getting implemented? You mentioned 'next version' back in 2015 and closed #11 last year (the title of which more closely matches what I'm thinking for this issue)
In the meantime, @Sugarcaen / @jfmmm how would you use gulp-strip-comments (or something else?) to only remove the empty/remaining '[rR]emoveIf lines? Seems like there's only an 'ignore' regex option there - no explicit 'remove only matches' option.
I'd love to be able to [at least somewhat] cleanly strip all 'true' removeIf sections as well as specifically the '[rR]emoveIf' comments from all 'false' removeIf sections...
jfmmm commentedon Mar 20, 2018
Looking at it I don't see how you would do that.. It would need some way to pass a regex or something.
Don't remember how I ended up fixing that and don't have access to that project anymore sadly.
Sugarcaen commentedon Mar 20, 2018
I just want to make sure I'm understanding you, @JoshuaSCochrane, its been a while since I've touched a project using gulp.
You want to pipe something like:
And get:
Correct?
JoshuaSCochrane commentedon Mar 21, 2018
@Sugarcaen precisely, except ideally controlled by an additional option to the gulp
removeCodepart, like if you have.pipe(removeCode({ production: true }, options.removeInactiveMarkers: true ))(or however you specify options - not quite clear and no examples in the readme). Or perhaps an addition to the markers themselves, something like//removeIf(production, markerEvenIfFalse: true)\//endRemoveIf(production)so you can control it on a marker-by-marker basis (though I can't imagine why you'd want to keep any inactive markers, maybe someone does)...I honestly very briefly considered doing something like this (contrived example):
(so it would remove configBThing if config_A but always remove the removeIfs) but then I realized how abysmally ugly that was going to get and may not even work anyway... :p
mckravchyk commentedon Sep 4, 2020
You can clean it up with gulp-delete-lines
Note: This assumes that you use strictly //removeIf and //endRemoveIf comments with no space in-between.
Update:
Using gulp-delete-lines instead of gulp-replace to remove whole lines.
Cristy94 commentedon Feb 27, 2021
I also encountered this issue/feature request. I have a feature toggle
removeIf(!featureA)which correctly remove the code if the featureA is disabled, but if it's enabled I just want to keep the code without theremoveIfcomment being there.The
gulp-delete-linessolution sounds good, maybe it could be integrated in the core options as @JoshuaSCochrane mentioned.I used this: