@@ -84,23 +84,23 @@ gulp.task('Iconfont', async () => {
8484 const iconfontModule = await import ( 'gulp-iconfont' ) ;
8585
8686 // Extract the function - CommonJS modules use .default when imported via dynamic import()
87- // Try .default first, then fallback to the module itself
88- const iconfontFn = ( typeof iconfontModule . default === 'function' )
89- ? iconfontModule . default
90- : ( typeof iconfontModule === 'function' ? iconfontModule : iconfontModule . default || iconfontModule ) ;
91-
87+ let iconfontFn = iconfontModule . default ;
88+ if ( typeof iconfontFn !== 'function' ) {
89+ iconfontFn = iconfontModule ;
90+ }
9291 if ( typeof iconfontFn !== 'function' ) {
9392 throw new Error (
9493 `gulp-iconfont is not a function. ` +
9594 `Got: ${ typeof iconfontFn } , ` +
9695 `default: ${ typeof iconfontModule . default } , ` +
97- `module: ${ typeof iconfontModule } `
96+ `module: ${ typeof iconfontModule } , ` +
97+ `keys: ${ Object . keys ( iconfontModule ) . join ( ', ' ) } `
9898 ) ;
9999 }
100100
101- // Create options object - use plain object literal to ensure compatibility
101+ // Create options object with fontName as the first property to ensure it's present
102102 const iconfontOptions = {
103- fontName : 'iconFont' ,
103+ fontName : 'iconFont' , // Required by svgicons2svgfont
104104 prependUnicode : true ,
105105 formats : [ 'ttf' , 'eot' , 'woff' , 'svg' ] ,
106106 normalize : true ,
@@ -110,12 +110,13 @@ gulp.task('Iconfont', async () => {
110110 centerHorizontally : false ,
111111 } ;
112112
113- // Double-check fontName exists and is a string
114- if ( ! iconfontOptions . fontName || typeof iconfontOptions . fontName !== 'string' ) {
115- throw new Error ( `fontName is required but got: ${ iconfontOptions . fontName } ( ${ typeof iconfontOptions . fontName } ) ` ) ;
113+ // Ensure fontName is a non-empty string
114+ if ( ! iconfontOptions . fontName || typeof iconfontOptions . fontName !== 'string' || iconfontOptions . fontName . length === 0 ) {
115+ throw new Error ( `fontName must be a non-empty string, got: ${ JSON . stringify ( iconfontOptions . fontName ) } ` ) ;
116116 }
117117
118118 // Call the function directly with options
119+ // The function signature is: function gulpFontIcon(options)
119120 return gulp
120121 . src ( [ 'assets/img/icons/*.svg' ] )
121122 . pipe ( iconfontFn ( iconfontOptions ) )
0 commit comments