Skip to content

Commit

Permalink
feat: use config schema from core
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Jul 1, 2020
1 parent f4e51e3 commit 0eaecac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"yeoman-environment": "2.8.1",
"yeoman-generator": "4.7.2"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x"
},
"devDependencies": {
"@types/got": "9.6.9",
"@types/prettier": "1.19.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/utils/src/isWebpack5.ts
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');
40 changes: 38 additions & 2 deletions packages/utils/src/prop-types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
// eslint-disable-next-line node/no-extraneous-import
import { isWebpack5 } from './isWebpack5';
import { config } from 'webpack';
const configKeys = Object.keys(config.getNormalizedWebpackOptions({}));

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',
];
}

/**
*
Expand Down

0 comments on commit 0eaecac

Please sign in to comment.