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
Preserve all directive comments and omitted lines as comments. Basically for debugging purpose.
371
+
Preserve all directive comments and omitted lines as comments. Basically for debugging purpose. Note that the normal comments remain as-is(except padding).
371
372
372
373
Given:
373
374
374
375
```javascript
375
376
// options.params.ENV === 'product'
376
377
377
378
// #!if ENV === 'develop'
378
-
/** some comment */
379
+
/** some comment */
379
380
console.log("many doge");
380
381
// #!else
381
382
console.log("much wow");
@@ -384,15 +385,65 @@ console.log("much wow");
384
385
385
386
If set to `true`, yields:
386
387
388
+
<!-- prettier-ignore -->
387
389
```javascript
388
390
// #!if ENV === 'develop'
389
-
// /** some comment */
391
+
/** some comment */
390
392
// console.log('many doge');
391
393
// #!else
392
394
console.log("much wow");
393
395
// #!endif
394
396
```
395
397
398
+
#### `escapeComments`
399
+
400
+
> default: `false`
401
+
402
+
There are rare cases where multiple kinds of comment notations live within the same control block. For example:
403
+
404
+
```html
405
+
<body>
406
+
<!-- #!if foo === 1-->
407
+
<style>
408
+
.div {
409
+
/* comment because of reasons */
410
+
color: tomato;
411
+
}
412
+
</style>
413
+
<script>
414
+
/**
415
+
* another multiline comment
416
+
417
+
*/
418
+
constbar=1;
419
+
</script>
420
+
<!-- #!endif -->
421
+
</body>
422
+
```
423
+
424
+
If `foo === 2`, the comments in `style` and `script` tag will stay as-is and "leak" into outside code. To prevent unwanted results, set `escapeComments` to `true`. All _non-directive_ comment notations will be replaced by `@@`, and re-wrapped by those used in the previous directive:
425
+
426
+
<!-- prettier-ignore -->
427
+
```html
428
+
<body>
429
+
<!-- #!if foo === 1-->
430
+
<!-- <style>-->
431
+
<!-- .div {-->
432
+
<!-- @@ comment because of reasons @@-->
433
+
<!-- color: tomato;-->
434
+
<!-- }-->
435
+
<!-- </style>-->
436
+
<!-- <script>-->
437
+
<!-- @@*-->
438
+
<!-- * another multiline comment-->
439
+
<!---->
440
+
<!-- @@-->
441
+
<!-- const bar = 1;-->
442
+
<!-- </script>-->
443
+
<!-- #!endif -->
444
+
</body>
445
+
```
446
+
396
447
## Built-in Directives
397
448
398
449
### `#!if` / `#!else` / `#!elseif` / `#!endif`
@@ -546,6 +597,10 @@ module.exports = {
546
597
};
547
598
```
548
599
600
+
## Changelog
601
+
602
+
See [Github Release Page](https://github.com/afterwind-io/preprocessor-loader/releases).
0 commit comments