@@ -43,7 +43,7 @@ function parseFontIconValue (value) {
4343 * Returns a promise with the result of all `icon-font:url(...)` svg paths of the given file
4444 *
4545 * @param postCssRoot {postcss.Root} The name of the font (font-family)
46- * @param webpackResolve {function } The webpack resolve helper
46+ * @param webpackResolve {(context: string, path: string, callback: (err: any, result: string) => void) => void } The webpack resolve helper
4747 * @param context {string} The css loader path context to resolve relative urls
4848 *
4949 * @returns {Promise<{resolved: string[], unresolved: string[], relative: string[]}> }
@@ -85,7 +85,7 @@ function getSvgPaths (postCssRoot, webpackResolve, context) {
8585
8686/**
8787 * @param fontName {string} The name of the font (font-family)
88- * @param postCssRoot {object } The postCss root object
88+ * @param postCssRoot {postcss.Root } The postCss root object
8989 * @param svgPaths {object} The svg path information
9090 */
9191function replaceIconFontDeclarations ( fontName , postCssRoot , svgPaths ) {
@@ -170,10 +170,14 @@ function addFontDeclaration (fontName, postCssRoot, enforcedSvgHeight, svgPaths)
170170 * PostCSS Plugin factory
171171 */
172172module . exports = postcss . plugin ( 'iconfont-webpack' , config => function ( root , result ) {
173+ /* istanbul ignore if: Skip processing empty results */
174+ if ( ! result || ! result . opts || ! result . opts . from ) {
175+ return ;
176+ }
173177 const cssFilename = result . opts . from ;
174178 const context = path . dirname ( cssFilename ) ;
175179 return getSvgPaths ( root , config . resolve , context )
176- . then ( function ( svgPaths ) {
180+ . then ( /** @returns { any } */ function ( svgPaths ) {
177181 // Stop if the css file contains no `font-icon:url('..');` declarations
178182 if ( svgPaths . resolved . length === 0 ) {
179183 return ;
0 commit comments