2121 * @import { OptionsCallback } from './utils/apply-options-callback.js'
2222 */
2323
24+ /**
25+ * @import { CopyFilesOptions } from '../index.js'
26+ */
27+
2428const path = require ( 'path' ) ;
2529const fs = require ( 'fs' ) ;
2630const crypto = require ( 'crypto' ) ;
@@ -80,12 +84,14 @@ class WebpackConfig {
8084 this . cleanupOutput = false ;
8185 this . usePersistentCache = false ;
8286 this . extractCss = true ;
87+ /** @type {{filename: string, maxSize: number|null, type: string, enabled: boolean} } */
8388 this . imageRuleOptions = {
8489 type : 'asset/resource' ,
8590 maxSize : null ,
8691 filename : 'images/[name].[hash:8][ext]' ,
8792 enabled : true ,
8893 } ;
94+ /** @type {{filename: string, maxSize: number|null, type: string, enabled: boolean} } */
8995 this . fontRuleOptions = {
9096 type : 'asset/resource' ,
9197 maxSize : null ,
@@ -109,13 +115,17 @@ class WebpackConfig {
109115
110116 // Features/Loaders options
111117 this . copyFilesConfigs = [ ] ;
118+ /**
119+ * @type {{resolveUrlLoader: boolean, resolveUrlLoaderOptions: object} }
120+ */
112121 this . sassOptions = {
113122 resolveUrlLoader : true ,
114123 resolveUrlLoaderOptions : { }
115124 } ;
116125 this . preactOptions = {
117126 preactCompat : false
118127 } ;
128+ /** @type {{exclude: webpack.RuleSetCondition, useBuiltIns: 'usage'|'entry'|false, corejs: number|string|{ version: string, proposals: boolean }|null} } */
119129 this . babelOptions = {
120130 exclude : / ( n o d e _ m o d u l e s | b o w e r _ c o m p o n e n t s ) / ,
121131 useBuiltIns : false ,
@@ -127,6 +137,7 @@ class WebpackConfig {
127137 version : null ,
128138 runtimeCompilerBuild : null
129139 } ;
140+ /** @type {Record<string, string[]> } */
130141 this . persistentCacheBuildDependencies = { } ;
131142
132143 // Features/Loaders options callbacks
@@ -428,7 +439,7 @@ class WebpackConfig {
428439
429440 /**
430441 * @param {OptionsCallback<object>|null } callback
431- * @param {object } options
442+ * @param {{exclude?: webpack.RuleSetCondition, includeNodeModules?: string[], useBuiltIns?: 'usage' | 'entry' | false, corejs?: number|string|{ version: string, proposals: boolean }|null} } options
432443 */
433444 configureBabel ( callback , options = { } ) {
434445 if ( callback ) {
@@ -590,6 +601,10 @@ class WebpackConfig {
590601 this . devServerOptionsConfigurationCallback = callback ;
591602 }
592603
604+ /**
605+ * @param {string } name
606+ * @param {object } options
607+ */
593608 addCacheGroup ( name , options ) {
594609 if ( typeof name !== 'string' ) {
595610 throw new Error ( 'Argument 1 to addCacheGroup() must be a string.' ) ;
@@ -620,6 +635,9 @@ class WebpackConfig {
620635 this . cacheGroups [ name ] = options ;
621636 }
622637
638+ /**
639+ * @param {CopyFilesOptions|CopyFilesOptions[] } configs
640+ */
623641 copyFiles ( configs = [ ] ) {
624642 if ( ! Array . isArray ( configs ) ) {
625643 configs = [ configs ] ;
@@ -683,7 +701,7 @@ class WebpackConfig {
683701
684702 /**
685703 * @param {OptionsCallback<object> } sassLoaderOptionsCallback
686- * @param {object } options
704+ * @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object} } options
687705 */
688706 enableSassLoader ( sassLoaderOptionsCallback = ( ) => { } , options = { } ) {
689707 this . useSassLoader = true ;
@@ -750,7 +768,7 @@ class WebpackConfig {
750768 }
751769
752770 /**
753- * @param {object } buildDependencies
771+ * @param {Record<string, string[]> } buildDependencies
754772 * @param {OptionsCallback<webpack.FileCacheOptions> } callback
755773 */
756774 enableBuildCache ( buildDependencies , callback = ( cache ) => { } ) {
@@ -916,7 +934,7 @@ class WebpackConfig {
916934 }
917935
918936 /**
919- * @param {object } options
937+ * @param {{filename?: string, maxSize?: number|null, type?: string, enabled?: boolean} } options
920938 * @param {OptionsCallback<webpack.RuleSetRule> } ruleCallback
921939 */
922940 configureImageRule ( options = { } , ruleCallback = ( ) => { } ) {
@@ -940,7 +958,7 @@ class WebpackConfig {
940958 }
941959
942960 /**
943- * @param {object } options
961+ * @param {{filename?: string, maxSize?: number|null, type?: string, enabled?: boolean} } options
944962 * @param {OptionsCallback<webpack.RuleSetRule> } ruleCallback
945963 */
946964 configureFontRule ( options = { } , ruleCallback = ( ) => { } ) {
0 commit comments