-
-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[utils]: opt to use config schema from core (#1655)
* chore: remove hardcoded config options from utils, use from core * chore: use config schema from core * chore: use config schema from core * chore: use config schema from core * chore: use config schema from core * feat: use config schema from core
- Loading branch information
Showing
5 changed files
with
49 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { version } from 'webpack'; | ||
|
||
export const isWebpack5 = (): boolean => version.startsWith('5'); |
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 |
---|---|---|
@@ -1,38 +1,47 @@ | ||
import { isWebpack5 } from './isWebpack5'; | ||
import { config } from 'webpack'; | ||
|
||
let configKeys; | ||
if (isWebpack5()) { | ||
configKeys = Object.keys(config.getNormalizedWebpackOptions({})); | ||
} else { | ||
configKeys = [ | ||
'amd', | ||
'bail', | ||
'cache', | ||
'context', | ||
'devServer', | ||
'devtool', | ||
'entry', | ||
'externals', | ||
'merge', | ||
'mode', | ||
'module', | ||
'node', | ||
'optimization', | ||
'output', | ||
'parallelism', | ||
'performance', | ||
'plugins', | ||
'profile', | ||
'recordsInputPath', | ||
'recordsOutputPath', | ||
'recordsPath', | ||
'resolve', | ||
'resolveLoader', | ||
'splitChunks', | ||
'stats', | ||
'target', | ||
'topScope', | ||
'watch', | ||
'watchOptions', | ||
]; | ||
} | ||
|
||
/** | ||
* | ||
* A Set of all accepted properties | ||
* | ||
* @returns {Set} A new set with accepted webpack properties | ||
*/ | ||
|
||
export const PROP_TYPES: Set<string> = new Set([ | ||
'amd', | ||
'bail', | ||
'cache', | ||
'context', | ||
'devServer', | ||
'devtool', | ||
'entry', | ||
'externals', | ||
'merge', | ||
'mode', | ||
'module', | ||
'node', | ||
'optimization', | ||
'output', | ||
'parallelism', | ||
'performance', | ||
'plugins', | ||
'profile', | ||
'recordsInputPath', | ||
'recordsOutputPath', | ||
'recordsPath', | ||
'resolve', | ||
'resolveLoader', | ||
'splitChunks', | ||
'stats', | ||
'target', | ||
'topScope', | ||
'watch', | ||
'watchOptions', | ||
]); | ||
export const PROP_TYPES: Set<string> = new Set(configKeys); |
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