@@ -120,29 +120,35 @@ export default (api: IApi) => {
120120 } ) ;
121121
122122 // 增加检测 html 文件类型的功能
123- api . onBuildHtmlComplete ( async ( html : any ) => {
124- const htmlFiles = html ?. htmlFiles || [ ] ;
125- if ( api . env === 'development' || htmlFiles . length === 0 ) {
126- return ;
127- }
123+ api . onBuildHtmlComplete (
124+ async ( html : { htmlFiles ?: Array < { path : string } > } ) => {
125+ const htmlFiles = html ?. htmlFiles || [ ] ;
126+ if ( api . env === 'development' || htmlFiles . length === 0 ) {
127+ return ;
128+ }
128129
129- const targets = api . config . targets ;
130- const checkerOptions = getCheckSyntaxOptions ( targets ) ;
131- const checker = new CheckSyntax ( {
132- rootPath : api . paths . absOutputPath ,
133- ecmaVersion : 2015 as const , // 默认ES2015
134- ...checkerOptions ,
135- } ) ;
130+ const targets = api . config . targets ;
131+ const checkerOptions = getCheckSyntaxOptions ( targets ) ;
132+ const checker = new CheckSyntax ( {
133+ rootPath : api . paths . absOutputPath ,
134+ ecmaVersion : 2015 as const , // 默认ES2015
135+ ...checkerOptions ,
136+ } ) ;
136137
137- // 获取 dist 目录下的所有 html 文件
138- // 遍历 html 文件,检测是否存在语法错误
139- for ( const htmlFile of htmlFiles ) {
140- const htmlFilePath = winPath (
141- join ( api . paths . absOutputPath , htmlFile . path ) ,
142- ) ;
143- await checker . check ( htmlFilePath ) ;
144- }
138+ // 获取 dist 目录下的所有 html 文件
139+ // 遍历 html 文件,检测是否存在语法错误
140+ for ( const htmlFile of htmlFiles ) {
141+ const htmlFilePath = winPath (
142+ join ( api . paths . absOutputPath , htmlFile . path ) ,
143+ ) ;
144+ await checker . check ( htmlFilePath ) ;
145+ }
145146
146- printErrors ( checker . errors , checker . ecmaVersion , checker . excludeErrorLogs ) ;
147- } ) ;
147+ printErrors (
148+ checker . errors ,
149+ checker . ecmaVersion ,
150+ checker . excludeErrorLogs ,
151+ ) ;
152+ } ,
153+ ) ;
148154} ;
0 commit comments