21
21
* @import { OptionsCallback } from './utils/apply-options-callback.js'
22
22
*/
23
23
24
+ /**
25
+ * @import { CopyFilesOptions } from '../index.js'
26
+ */
27
+
24
28
const path = require ( 'path' ) ;
25
29
const fs = require ( 'fs' ) ;
26
30
const crypto = require ( 'crypto' ) ;
@@ -80,12 +84,14 @@ class WebpackConfig {
80
84
this . cleanupOutput = false ;
81
85
this . usePersistentCache = false ;
82
86
this . extractCss = true ;
87
+ /** @type {{filename: string, maxSize: number|null, type: string, enabled: boolean} } */
83
88
this . imageRuleOptions = {
84
89
type : 'asset/resource' ,
85
90
maxSize : null ,
86
91
filename : 'images/[name].[hash:8][ext]' ,
87
92
enabled : true ,
88
93
} ;
94
+ /** @type {{filename: string, maxSize: number|null, type: string, enabled: boolean} } */
89
95
this . fontRuleOptions = {
90
96
type : 'asset/resource' ,
91
97
maxSize : null ,
@@ -109,13 +115,17 @@ class WebpackConfig {
109
115
110
116
// Features/Loaders options
111
117
this . copyFilesConfigs = [ ] ;
118
+ /**
119
+ * @type {{resolveUrlLoader: boolean, resolveUrlLoaderOptions: object} }
120
+ */
112
121
this . sassOptions = {
113
122
resolveUrlLoader : true ,
114
123
resolveUrlLoaderOptions : { }
115
124
} ;
116
125
this . preactOptions = {
117
126
preactCompat : false
118
127
} ;
128
+ /** @type {{exclude: webpack.RuleSetCondition, useBuiltIns: 'usage'|'entry'|false, corejs: number|string|{ version: string, proposals: boolean }|null} } */
119
129
this . babelOptions = {
120
130
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 ) / ,
121
131
useBuiltIns : false ,
@@ -127,6 +137,7 @@ class WebpackConfig {
127
137
version : null ,
128
138
runtimeCompilerBuild : null
129
139
} ;
140
+ /** @type {Record<string, string[]> } */
130
141
this . persistentCacheBuildDependencies = { } ;
131
142
132
143
// Features/Loaders options callbacks
@@ -428,7 +439,7 @@ class WebpackConfig {
428
439
429
440
/**
430
441
* @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
432
443
*/
433
444
configureBabel ( callback , options = { } ) {
434
445
if ( callback ) {
@@ -590,6 +601,10 @@ class WebpackConfig {
590
601
this . devServerOptionsConfigurationCallback = callback ;
591
602
}
592
603
604
+ /**
605
+ * @param {string } name
606
+ * @param {object } options
607
+ */
593
608
addCacheGroup ( name , options ) {
594
609
if ( typeof name !== 'string' ) {
595
610
throw new Error ( 'Argument 1 to addCacheGroup() must be a string.' ) ;
@@ -620,6 +635,9 @@ class WebpackConfig {
620
635
this . cacheGroups [ name ] = options ;
621
636
}
622
637
638
+ /**
639
+ * @param {CopyFilesOptions|CopyFilesOptions[] } configs
640
+ */
623
641
copyFiles ( configs = [ ] ) {
624
642
if ( ! Array . isArray ( configs ) ) {
625
643
configs = [ configs ] ;
@@ -683,7 +701,7 @@ class WebpackConfig {
683
701
684
702
/**
685
703
* @param {OptionsCallback<object> } sassLoaderOptionsCallback
686
- * @param {object } options
704
+ * @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object} } options
687
705
*/
688
706
enableSassLoader ( sassLoaderOptionsCallback = ( ) => { } , options = { } ) {
689
707
this . useSassLoader = true ;
@@ -750,7 +768,7 @@ class WebpackConfig {
750
768
}
751
769
752
770
/**
753
- * @param {object } buildDependencies
771
+ * @param {Record<string, string[]> } buildDependencies
754
772
* @param {OptionsCallback<webpack.FileCacheOptions> } callback
755
773
*/
756
774
enableBuildCache ( buildDependencies , callback = ( cache ) => { } ) {
@@ -916,7 +934,7 @@ class WebpackConfig {
916
934
}
917
935
918
936
/**
919
- * @param {object } options
937
+ * @param {{filename?: string, maxSize?: number|null, type?: string, enabled?: boolean} } options
920
938
* @param {OptionsCallback<webpack.RuleSetRule> } ruleCallback
921
939
*/
922
940
configureImageRule ( options = { } , ruleCallback = ( ) => { } ) {
@@ -940,7 +958,7 @@ class WebpackConfig {
940
958
}
941
959
942
960
/**
943
- * @param {object } options
961
+ * @param {{filename?: string, maxSize?: number|null, type?: string, enabled?: boolean} } options
944
962
* @param {OptionsCallback<webpack.RuleSetRule> } ruleCallback
945
963
*/
946
964
configureFontRule ( options = { } , ruleCallback = ( ) => { } ) {
0 commit comments