mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 22:21:27 +08:00
CLI: Limit preset install for old versions of SB
This commit is contained in:
parent
2744fb78ba
commit
c8ad08828c
@ -27,12 +27,15 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
|
||||
)?.version;
|
||||
const isCra5 = semver.gte(craVersion, '5.0.0');
|
||||
const updatedOptions = isCra5 ? { ...options, builder: CoreBuilder.Webpack5 } : options;
|
||||
// `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
|
||||
const extraPackages = ['@storybook/node-logger'];
|
||||
if (isCra5) extraPackages.push('webpack');
|
||||
|
||||
// preset v3 is compat with older versions of CRA, otherwise let version float
|
||||
const extraAddons = [`@storybook/preset-create-react-app${isCra5 ? '' : '@3'}`];
|
||||
|
||||
await baseGenerator(packageManager, npmOptions, updatedOptions, 'react', {
|
||||
extraAddons: ['@storybook/preset-create-react-app'],
|
||||
// `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
|
||||
extraAddons,
|
||||
extraPackages,
|
||||
staticDir: fs.existsSync(path.resolve('./public')) ? 'public' : undefined,
|
||||
addBabel: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user