Open leolux opened 7 years ago
As the documentation says: "Specifying true will strip comments which do not match the current target" In my case this means that the destination file still contains all unprocessed script elements but without comments. Removing the comments is fine but how to remove the block content when the build target is unmatched?
Could you provide a short example of the input -> output you seek?
Ok, I got it! It is possible to have multiple targets seperated by comma. This allows me to remove the block for a certain target. A nice feature would be to have a target which includes the block only on a matched target thus all unmatched targets get removed automatically.
To complete with an example:
<!-- build:remove:dist,js:dev inline -->
<script src="my/lib/path/lib.js"></script>
<!-- /build -->
This special comment combines "remove:dist" with "js:dev inline". Running "grunt dev" will replace the script element with the corresponding inline javascript. And running "grunt dist" will write nothing to the destination file.
Im am not sure why this syntax actually works because the documentation only says that you canpass multiple comma-separated targets and but not multiple types. In my example I passed multiple build types with a single target for each type. Is my syntax valid in your eyes?
Update: "grunt dev" does not inline the javascript so the example does not work as intended.
hm i see thanks for the feedback. we'll see if this comes up again to make it a feature. not many grunt users anymore though.
however this maybe more useful to include directly in the core parser https://github.com/dciccale/node-htmlprocessor will keep it in mind
Your example seems incomplete
I am having problems escaping comments in markdown code. Now it looks fine :-)
Update: The example does not work as expected for "grunt dev" because the script does not get inlined. So the syntax given in the example is wrong. Is it even possible to pass multiple types in the comment ("remove" and "js")?
Currently every block gets written to the destination file even when the build target does not match the block target. But this results in too many blocks within the destination file (each for every target).
Is there a way to completely exclude/omit blocks based on the build target? Or is it possible to combine or nest "build:remove:dev" with "build:js:dist inline" somehow to achive the desired effect?