feat: add clone() method

This commit is contained in:
Christopher Willis-Ford 2024-03-08 20:07:13 -08:00
parent 044d389ee2
commit c2f5451022

View file

@ -35,6 +35,7 @@ class ScratchWebpackConfigBuilder {
const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';
this._libraryName = libraryName;
this._rootPath = toPath(rootPath) || '.'; // '.' will cause a webpack error since src must be absolute
this._srcPath = toPath(srcPath) ?? path.resolve(this._rootPath, 'src');
this._distPath = toPath(distPath) ?? path.resolve(this._rootPath, 'dist');
@ -77,6 +78,18 @@ class ScratchWebpackConfigBuilder {
};
}
/**
* @returns {ScratchWebpackConfigBuilder} a copy of the current configuration builder.
*/
clone() {
return new ScratchWebpackConfigBuilder({
libraryName: this._libraryName,
rootPath: this._rootPath,
srcPath: this._srcPath,
distPath: this._distPath
}).merge(this._config);
}
/**
* @returns {Configuration} a copy of the current configuration object.
*/