-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.d.ts
60 lines (50 loc) · 1.68 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
export interface Options {
/**
- `true` - Preserve important comments `/*! *\/`.
- `false` - Strip all comments.
- `RegExp` - Preserve comments where the comment body matches a regular expression.
- `Function` - Preserve comments for which a function returns `true`. The function is called on each comment, gets the comment body as the first argument, and is expected to return a boolean of whether to preserve the comment.
@default true
*/
readonly preserve?: boolean | RegExp | ((comment: string) => boolean);
/**
Replace comments with whitespace instead of stripping them entirely.
@default true
*/
readonly whitespace?: boolean;
}
/**
Strip comments from CSS.
@param cssString - String with CSS.
@example
```
import stripCssComments from 'strip-css-comments';
// By default important comments `/*!` are preserved
stripCssComments('/*! <copyright> *\/ body { /* unicorns *\/color: hotpink; }');
//=> '/*! <copyright> *\/ body { color: hotpink; }'
// `preserve: false` will strip all comments including `/*!`
stripCssComments(
'/*! <copyright> *\/ body { /* unicorns *\/color: hotpink; }',
{preserve: false}
);
//=> 'body { color: hotpink; }'
// Preserve comments based on a regex
stripCssComments(
'/*# preserved *\/ body { /* unicorns *\/color: hotpink; }',
{preserve: /^#/}
);
//=> '/*# preserved *\/ body { color: hotpink; }'
// Preserve comments based on the return value of the supplied function
stripCssComments(
'/*# preserved *\/ body { /* unicorns *\/color: hotpink; }',
{
preserve: comment => comment.charAt(0) === '#'
}
);
//=> '/*# preserved *\/ body { color: hotpink; }'
```
*/
export default function stripCssComments(
cssString: string,
options?: Options
): string;