mirror of
https://github.com/scratchfoundation/scratch-webpack-configuration.git
synced 2025-02-20 04:14:27 -05:00
feat: add clone() method
This commit is contained in:
parent
044d389ee2
commit
c2f5451022
1 changed files with 13 additions and 0 deletions
|
@ -35,6 +35,7 @@ class ScratchWebpackConfigBuilder {
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const mode = isProduction ? 'production' : 'development';
|
const mode = isProduction ? 'production' : 'development';
|
||||||
|
|
||||||
|
this._libraryName = libraryName;
|
||||||
this._rootPath = toPath(rootPath) || '.'; // '.' will cause a webpack error since src must be absolute
|
this._rootPath = toPath(rootPath) || '.'; // '.' will cause a webpack error since src must be absolute
|
||||||
this._srcPath = toPath(srcPath) ?? path.resolve(this._rootPath, 'src');
|
this._srcPath = toPath(srcPath) ?? path.resolve(this._rootPath, 'src');
|
||||||
this._distPath = toPath(distPath) ?? path.resolve(this._rootPath, 'dist');
|
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.
|
* @returns {Configuration} a copy of the current configuration object.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue