Skip to content

Commit c2f5451

Browse files
committed
feat: add clone() method
1 parent 044d389 commit c2f5451

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/index.cjs

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ScratchWebpackConfigBuilder {
3535
const isProduction = process.env.NODE_ENV === 'production';
3636
const mode = isProduction ? 'production' : 'development';
3737

38+
this._libraryName = libraryName;
3839
this._rootPath = toPath(rootPath) || '.'; // '.' will cause a webpack error since src must be absolute
3940
this._srcPath = toPath(srcPath) ?? path.resolve(this._rootPath, 'src');
4041
this._distPath = toPath(distPath) ?? path.resolve(this._rootPath, 'dist');
@@ -77,6 +78,18 @@ class ScratchWebpackConfigBuilder {
7778
};
7879
}
7980

81+
/**
82+
* @returns {ScratchWebpackConfigBuilder} a copy of the current configuration builder.
83+
*/
84+
clone() {
85+
return new ScratchWebpackConfigBuilder({
86+
libraryName: this._libraryName,
87+
rootPath: this._rootPath,
88+
srcPath: this._srcPath,
89+
distPath: this._distPath
90+
}).merge(this._config);
91+
}
92+
8093
/**
8194
* @returns {Configuration} a copy of the current configuration object.
8295
*/

0 commit comments

Comments
 (0)