Skip to content

Commit

Permalink
Merge branch 'master' into bugs/enable-vitejs-plugin-react-swc
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Aug 15, 2024
2 parents f2e6fb7 + ce2dff3 commit b83bbf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { StorybookConfigureSchema } from './schema';
import storiesGenerator from '../stories/stories';
import {
addDependenciesToPackageJson,
ensurePackage,
formatFiles,
type GeneratorCallback,
joinPathFragments,
readNxJson,
readProjectConfiguration,
runTasksInSerial,
Tree,
} from '@nx/devkit';
import { nxVersion } from '../../utils/versions';
import { nxVersion, reactViteVersion } from '../../utils/versions';

async function generateStories(host: Tree, schema: StorybookConfigureSchema) {
// TODO(katerina): Nx 19 -> remove Cypress
Expand Down Expand Up @@ -48,6 +51,7 @@ export async function storybookConfigurationGeneratorInternal(
host: Tree,
schema: StorybookConfigureSchema
) {
const tasks: GeneratorCallback[] = [];
const nxJson = readNxJson(host);
const addPluginDefault =
process.env.NX_ADD_PLUGINS !== 'false' &&
Expand All @@ -69,6 +73,16 @@ export async function storybookConfigurationGeneratorInternal(
uiFramework = '@storybook/react-webpack5';
}

if (uiFramework === '@storybook/react-vite') {
tasks.push(
addDependenciesToPackageJson(
host,
{},
{ '@vitejs/plugin-react': reactViteVersion }
)
);
}

const installTask = await configurationGenerator(host, {
project: schema.project,
configureCypress: schema.configureCypress,
Expand All @@ -83,13 +97,15 @@ export async function storybookConfigurationGeneratorInternal(
addPlugin: schema.addPlugin,
});

tasks.push(installTask);

if (schema.generateStories) {
await generateStories(host, schema);
}

await formatFiles(host);

return installTask;
return runTasksInSerial(...tasks);
}

export default storybookConfigurationGenerator;
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const babelLoaderVersion = '^9.1.2';
export const typesReactVersion = '18.3.1';
export const typesReactDomVersion = '18.3.0';
export const typesReactIsVersion = '18.3.0';
export const reactViteVersion = '^4.2.0';

export const typesNodeVersion = '18.16.9';

Expand Down

0 comments on commit b83bbf0

Please sign in to comment.