mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 21:51:17 +08:00
Add support for CRA without overrides
This commit is contained in:
parent
12f90f2473
commit
3d78c71e32
@ -7,14 +7,12 @@ type Preset = string | { name: string };
|
||||
|
||||
// Disable the built-in preset if the new preset is detected.
|
||||
const checkForNewPreset = (presetsList: Preset[]) => {
|
||||
try {
|
||||
const hasNewPreset = presetsList.some((preset: Preset) => {
|
||||
const presetName = typeof preset === 'string' ? preset : preset.name;
|
||||
return presetName === '@storybook/preset-create-react-app';
|
||||
});
|
||||
const hasNewPreset = presetsList.some((preset: Preset) => {
|
||||
const presetName = typeof preset === 'string' ? preset : preset.name;
|
||||
return presetName === '@storybook/preset-create-react-app';
|
||||
});
|
||||
|
||||
return hasNewPreset;
|
||||
} catch (e) {
|
||||
if (!hasNewPreset) {
|
||||
logger.warn('Storybook support for Create React App is now a separate preset.');
|
||||
logger.warn(
|
||||
'To get started with the new preset, simply add `@storybook/preset-create-react-app` to your project.'
|
||||
@ -22,6 +20,8 @@ const checkForNewPreset = (presetsList: Preset[]) => {
|
||||
logger.warn('The built-in preset will be disabled in Storybook 6.0.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export function webpackFinal(
|
||||
|
@ -3,7 +3,11 @@ import findUp from 'find-up';
|
||||
import path from 'path';
|
||||
import { logger } from '@storybook/node-logger';
|
||||
|
||||
export async function createDefaultWebpackConfig(storybookBaseConfig) {
|
||||
export async function createDefaultWebpackConfig(storybookBaseConfig, options) {
|
||||
if (options.presetsList.some(({ name }) => name === '@storybook/preset-create-react-app')) {
|
||||
return storybookBaseConfig;
|
||||
}
|
||||
|
||||
const postcssConfigFiles = [
|
||||
'.postcssrc',
|
||||
'.postcssrc.json',
|
||||
|
@ -6,7 +6,7 @@ import mergeConfigs from '../utils/merge-webpack-config';
|
||||
import { createDefaultWebpackConfig } from './base-webpack.config';
|
||||
|
||||
async function createFinalDefaultConfig(presets, config, options) {
|
||||
const defaultConfig = await createDefaultWebpackConfig(config);
|
||||
const defaultConfig = await createDefaultWebpackConfig(config, options);
|
||||
return presets.apply('webpackFinal', defaultConfig, options);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user