From c2f5451022f99951dd0a1725f5fb752514882229 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:07:13 -0800 Subject: [PATCH] feat: add clone() method --- src/index.cjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.cjs b/src/index.cjs index 1c565a9..66e3179 100644 --- a/src/index.cjs +++ b/src/index.cjs @@ -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. */