-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webpack-plugin): webpack 5 configuration factory (#2776)
* Add support for fn-based webpack config * Bind the preprocessConfig function * Correct getMainConfig test for async fn * Fix typo * Expose proper types at the API * Add tests * Add processConfig test * Add preprocessConfig overwrite test * fixes * promise form * await * await Co-authored-by: MOZGIII <mike-n@narod.ru>
- Loading branch information
Showing
7 changed files
with
281 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Configuration } from 'webpack'; | ||
import { ConfigurationFactory } from '../WebpackConfig'; | ||
|
||
const trivialConfigurationFactory = | ||
(config: Configuration): ConfigurationFactory => | ||
() => | ||
config; | ||
|
||
export type ConfigProcessor = (config: ConfigurationFactory) => Promise<Configuration>; | ||
|
||
// Ensure processing logic is run for both `Configuration` and | ||
// `ConfigurationFactory` config variants. | ||
const processConfig = async (processor: ConfigProcessor, config: Configuration | ConfigurationFactory): Promise<Configuration> => { | ||
const configFactory = typeof config === 'function' ? config : trivialConfigurationFactory(config); | ||
return processor(configFactory); | ||
}; | ||
|
||
export default processConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.