File tree Expand file tree Collapse file tree 6 files changed +44
-9
lines changed Expand file tree Collapse file tree 6 files changed +44
-9
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ BannerPluginOptions|See the type declarations below|[Optional parameter format](
36
36
``` ts
37
37
/**
38
38
* Some options from `vite.config.[ts|js]`
39
- * @tips This options type is supported since ` 0.2.0`
39
+ * @since 0.2.0
40
40
*/
41
41
export interface BannerPluginOptions {
42
42
/**
@@ -52,10 +52,19 @@ export interface BannerPluginOptions {
52
52
53
53
/**
54
54
* Whether to print error messages to the console
55
- * @tips This option is supported since ` 0.4.0`
55
+ * @since 0.4.0
56
56
* @default `false`
57
57
*/
58
58
debug? : boolean
59
+
60
+ /**
61
+ * By default, the validity of the content will be verified.
62
+ * If set to `false`, no verification will be performed.
63
+ * @see https://github.com/chengpeiquan/vite-plugin-banner/issues/13
64
+ * @since 0.5.0
65
+ * @default `true`
66
+ */
67
+ verify? : boolean
59
68
}
60
69
```
61
70
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ BannerPluginOptions|请参阅下方的类型声明|[可选参数格式](#可选
36
36
``` ts
37
37
/**
38
38
* 来自 `vite.config.[ts|js]` 的一些选项
39
- * @tips 从 ` 0.2.0` 开始支持此选项类型
39
+ * @since 0.2.0
40
40
*/
41
41
export interface BannerPluginOptions {
42
42
/**
@@ -52,10 +52,18 @@ export interface BannerPluginOptions {
52
52
53
53
/**
54
54
* 是否将错误信息打印到控制台
55
- * @tips 从 ` 0.4.0` 开始支持此选项
55
+ * @since 0.4.0
56
56
* @default `false`
57
57
*/
58
58
debug? : boolean
59
+
60
+ /**
61
+ * 默认会验证内容的合法性,设置为 `false` 则不验证
62
+ * @see https://github.com/chengpeiquan/vite-plugin-banner/issues/13
63
+ * @since 0.5.0
64
+ * @default `true`
65
+ */
66
+ verify? : boolean
59
67
}
60
68
```
61
69
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vite-plugin-banner" ,
3
3
"description" : " A banner plugin for Vite. Adds a banner to the top of each generated chunk." ,
4
- "version" : " 0.4 .0" ,
4
+ "version" : " 0.5 .0" ,
5
5
"author" :
" chengpeiquan <[email protected] >" ,
6
6
"license" : " MIT" ,
7
7
"homepage" : " https://github.com/chengpeiquan/vite-plugin-banner" ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export default function formatConfig(
14
14
content : '' ,
15
15
outDir : 'dist' ,
16
16
debug : false ,
17
+ verify : true ,
17
18
}
18
19
19
20
// Type of plugin options
@@ -49,13 +50,20 @@ export default function formatConfig(
49
50
50
51
// Update the `debug` option
51
52
config . debug = Boolean ( options . debug )
53
+
54
+ // Update the `verify` option
55
+ if ( typeof options . verify === 'boolean' ) {
56
+ config . verify = options . verify
57
+ }
52
58
}
53
59
60
+ // No verification required
61
+ if ( ! config . verify ) return config
62
+
54
63
// Verify the validity of the incoming comment content
55
64
const errMsg : string = verifyBanner ( config . content )
56
65
if ( errMsg ) {
57
66
throw new Error ( `[vite-plugin-banner] ${ errMsg } ` )
58
67
}
59
-
60
68
return config
61
69
}
Original file line number Diff line number Diff line change 3
3
* @param content - The content of banner
4
4
* @return The error message, when success, if will be a empty string
5
5
*/
6
- export default function ( content : string ) : string {
6
+ export default function verifyBanner ( content : string ) : string {
7
7
// illegal type
8
8
if ( typeof content !== 'string' ) {
9
9
return 'The banner content must be a string.'
Original file line number Diff line number Diff line change 1
1
/**
2
2
* Some options from `vite.config.[ts|js]`
3
- * @tips This options type is supported since ` 0.2.0`
3
+ * @since 0.2.0
4
4
*/
5
5
export interface BannerPluginOptions {
6
6
/**
@@ -16,10 +16,19 @@ export interface BannerPluginOptions {
16
16
17
17
/**
18
18
* Whether to print error messages to the console
19
- * @tips This option is supported since ` 0.4.0`
19
+ * @since 0.4.0
20
20
* @default `false`
21
21
*/
22
22
debug ?: boolean
23
+
24
+ /**
25
+ * By default, the validity of the content will be verified.
26
+ * If set to `false`, no verification will be performed.
27
+ * @see https://github.com/chengpeiquan/vite-plugin-banner/issues/13
28
+ * @since 0.5.0
29
+ * @default `true`
30
+ */
31
+ verify ?: boolean
23
32
}
24
33
25
34
/**
@@ -29,4 +38,5 @@ export interface PluginConfig {
29
38
content : string
30
39
outDir : string
31
40
debug : boolean
41
+ verify : boolean
32
42
}
You can’t perform that action at this time.
0 commit comments