diff --git a/docs/generated/packages/react-native/generators/application.json b/docs/generated/packages/react-native/generators/application.json index 4100814e2fc7c2..658f7902791032 100644 --- a/docs/generated/packages/react-native/generators/application.json +++ b/docs/generated/packages/react-native/generators/application.json @@ -93,7 +93,7 @@ "type": "string", "enum": ["vite", "webpack"], "x-prompt": "Which bundler do you want to use to build the application?", - "default": "webpack", + "default": "vite", "x-priority": "important" } }, diff --git a/docs/generated/packages/react-native/generators/storybook-configuration.json b/docs/generated/packages/react-native/generators/storybook-configuration.json index e8233f36189fb7..f213f58be63767 100644 --- a/docs/generated/packages/react-native/generators/storybook-configuration.json +++ b/docs/generated/packages/react-native/generators/storybook-configuration.json @@ -73,6 +73,7 @@ } }, "required": ["project"], + "examplesFile": "This generator will set up Storybook for your **React Native** project.\n\n```bash\nnx g @nx/react-native:storybook-configuration project-name\n```\n\nWhen running this generator, you will be prompted to provide the following:\n\n- The `name` of the project you want to generate the configuration for.\n- Whether you want to set up [Storybook interaction tests](https://storybook.js.org/docs/react/writing-tests/interaction-testing) (`interactionTests`). If you choose `yes`, a `play` function will be added to your stories, and all the necessary dependencies will be installed. Also, a `test-storybook` target will be generated in your project's `project.json`, with a command to invoke the [Storybook `test-runner`](https://storybook.js.org/docs/react/writing-tests/test-runner). You can read more about this in the [Nx Storybook interaction tests documentation page](/recipes/storybook/storybook-interaction-tests#setup-storybook-interaction-tests)..\n- Whether you want to `generateStories` for the components in your project. If you choose `yes`, a `.stories.ts` file will be generated next to each of your components in your project.\n\nYou must provide a `name` for the generator to work.\n\nBy default, this generator will also set up [Storybook interaction tests](https://storybook.js.org/docs/react/writing-tests/interaction-testing). If you don't want to set up Storybook interaction tests, you can pass the `--interactionTests=false` option, but it's not recommended.\n\nThere are a number of other options available. Let's take a look at some examples.\n\n## Examples\n\n### Generate Storybook configuration\n\n```bash\nnx g @nx/react-native:storybook-configuration ui\n```\n\nThis will generate Storybook configuration for the `ui` project using TypeScript for the Storybook configuration files (the files inside the `.storybook` directory, eg. `.storybook/main.ts`).\n\n### Ignore certain paths when generating stories\n\n```bash\nnx g @nx/react-native:storybook-configuration ui --generateStories=true --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts\n```\n\nThis will generate a Storybook configuration for the `ui` project and generate stories for all components in the `libs/ui/src/lib` directory, except for the ones in the `libs/ui/src/not-stories` directory, and the ones in the `apps/my-app` directory that end with `.something.ts`, and also for components that their file name is of the pattern `*.other.*`.\n\nThis is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component.\n\nBy default, Nx will ignore the following paths:\n\n```text\n*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx\n```\n\nbut you can change this behaviour easily, as explained above.\n\n### Generate stories using JavaScript instead of TypeScript\n\n```bash\nnx g @nx/react-native:storybook-configuration ui --generateStories=true --js=true\n```\n\nThis will generate stories for all the components in the `ui` project using JavaScript instead of TypeScript. So, you will have `.stories.js` files next to your components.\n\n### Generate Storybook configuration using JavaScript\n\n```bash\nnx g @nx/react-native:storybook-configuration ui --tsConfiguration=false\n```\n\nBy default, our generator generates TypeScript Storybook configuration files. You can choose to use JavaScript for the Storybook configuration files of your project (the files inside the `.storybook` directory, eg. `.storybook/main.js`).\n", "presets": [] }, "description": "Set up Storybook for a React Native application or library.", diff --git a/docs/generated/packages/react-native/generators/web-configuration.json b/docs/generated/packages/react-native/generators/web-configuration.json index d472267f6b4ba9..ed8b4b6de0b780 100644 --- a/docs/generated/packages/react-native/generators/web-configuration.json +++ b/docs/generated/packages/react-native/generators/web-configuration.json @@ -34,7 +34,7 @@ "type": "string", "enum": ["vite", "webpack"], "x-prompt": "Which bundler do you want to use to build the application?", - "default": "webpack", + "default": "vite", "x-priority": "important" } }, diff --git a/e2e/react-native/src/react-native.test.ts b/e2e/react-native/src/react-native.test.ts index 544c01d279ef20..d04a05a3e87245 100644 --- a/e2e/react-native/src/react-native.test.ts +++ b/e2e/react-native/src/react-native.test.ts @@ -9,21 +9,43 @@ import { fileExists, checkFilesExist, runE2ETests, + updateFile, } from 'e2e/utils'; describe('@nx/react-native', () => { + let proj: string; let appName: string; + let libName: string; beforeAll(() => { - newProject(); + proj = newProject(); appName = uniq('app'); runCLI( `generate @nx/react-native:app ${appName} --install=false --no-interactive --unitTestRunner=jest --linter=eslint` ); + libName = uniq('lib'); + runCLI( + `generate @nx/react-native:lib ${libName} --no-interactive --unitTestRunner=jest --linter=eslint` + ); + const componentName = uniq('Component'); + runCLI( + `generate @nx/react-native:component libs/${libName}/src/lib/${componentName}/${componentName} --export --no-interactive` + ); + updateFile(`apps/${appName}/src/app/App.tsx`, (content) => { + let updated = `// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport {${componentName}} from '${proj}/${libName}';\n${content}`; + return updated; + }); }); afterAll(() => cleanupProject()); + it('should test and lint', async () => { + expect(() => runCLI(`test ${appName}`)).not.toThrow(); + expect(() => runCLI(`test ${libName}`)).not.toThrow(); + expect(() => runCLI(`lint ${appName}`)).not.toThrow(); + expect(() => runCLI(`lint ${libName}`)).not.toThrow(); + }); + it('should bundle the app', async () => { expect(() => runCLI( @@ -104,12 +126,28 @@ describe('@nx/react-native', () => { it('should create storybook with application', async () => { runCLI( - `generate @nx/react:storybook-configuration ${appName} --generateStories --no-interactive` + `generate @nx/react-native:storybook-configuration ${appName} --generateStories --no-interactive` ); checkFilesExist( `${appName}/.storybook/main.ts`, `${appName}/src/app/App.stories.tsx` ); + + runCLI(`build-storybook ${appName}`); + checkFilesExist(`${appName}/storybook-static/index.html`); + }); + + it('should create storybook with library', async () => { + runCLI( + `generate @nx/react-native:storybook-configuration ${libName} --generateStories --no-interactive` + ); + checkFilesExist( + `${libName}/.storybook/main.ts`, + `${libName}/src/app/App.stories.tsx` + ); + + runCLI(`build-storybook ${libName}`); + checkFilesExist(`${libName}/storybook-static/index.html`); }); it('should run build with vite bundler and e2e with playwright', async () => { @@ -137,5 +175,7 @@ describe('@nx/react-native', () => { `apps/${appName2}/.storybook/main.ts`, `apps/${appName2}/src/app/App.stories.tsx` ); + runCLI(`build-storybook ${appName2}`); + checkFilesExist(`${appName2}/storybook-static/index.html`); }); }); diff --git a/packages/react-native/docs/storybook-configuration-examples.md b/packages/react-native/docs/storybook-configuration-examples.md new file mode 100644 index 00000000000000..e7a2480512f54d --- /dev/null +++ b/packages/react-native/docs/storybook-configuration-examples.md @@ -0,0 +1,61 @@ +This generator will set up Storybook for your **React Native** project. + +```bash +nx g @nx/react-native:storybook-configuration project-name +``` + +When running this generator, you will be prompted to provide the following: + +- The `name` of the project you want to generate the configuration for. +- Whether you want to set up [Storybook interaction tests](https://storybook.js.org/docs/react/writing-tests/interaction-testing) (`interactionTests`). If you choose `yes`, a `play` function will be added to your stories, and all the necessary dependencies will be installed. Also, a `test-storybook` target will be generated in your project's `project.json`, with a command to invoke the [Storybook `test-runner`](https://storybook.js.org/docs/react/writing-tests/test-runner). You can read more about this in the [Nx Storybook interaction tests documentation page](/recipes/storybook/storybook-interaction-tests#setup-storybook-interaction-tests).. +- Whether you want to `generateStories` for the components in your project. If you choose `yes`, a `.stories.ts` file will be generated next to each of your components in your project. + +You must provide a `name` for the generator to work. + +By default, this generator will also set up [Storybook interaction tests](https://storybook.js.org/docs/react/writing-tests/interaction-testing). If you don't want to set up Storybook interaction tests, you can pass the `--interactionTests=false` option, but it's not recommended. + +There are a number of other options available. Let's take a look at some examples. + +## Examples + +### Generate Storybook configuration + +```bash +nx g @nx/react-native:storybook-configuration ui +``` + +This will generate Storybook configuration for the `ui` project using TypeScript for the Storybook configuration files (the files inside the `.storybook` directory, eg. `.storybook/main.ts`). + +### Ignore certain paths when generating stories + +```bash +nx g @nx/react-native:storybook-configuration ui --generateStories=true --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts +``` + +This will generate a Storybook configuration for the `ui` project and generate stories for all components in the `libs/ui/src/lib` directory, except for the ones in the `libs/ui/src/not-stories` directory, and the ones in the `apps/my-app` directory that end with `.something.ts`, and also for components that their file name is of the pattern `*.other.*`. + +This is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component. + +By default, Nx will ignore the following paths: + +```text +*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx +``` + +but you can change this behaviour easily, as explained above. + +### Generate stories using JavaScript instead of TypeScript + +```bash +nx g @nx/react-native:storybook-configuration ui --generateStories=true --js=true +``` + +This will generate stories for all the components in the `ui` project using JavaScript instead of TypeScript. So, you will have `.stories.js` files next to your components. + +### Generate Storybook configuration using JavaScript + +```bash +nx g @nx/react-native:storybook-configuration ui --tsConfiguration=false +``` + +By default, our generator generates TypeScript Storybook configuration files. You can choose to use JavaScript for the Storybook configuration files of your project (the files inside the `.storybook` directory, eg. `.storybook/main.js`). diff --git a/packages/react-native/src/generators/application/schema.json b/packages/react-native/src/generators/application/schema.json index 8bbc3a51c112ec..e6f1384e2d6407 100644 --- a/packages/react-native/src/generators/application/schema.json +++ b/packages/react-native/src/generators/application/schema.json @@ -93,7 +93,7 @@ "type": "string", "enum": ["vite", "webpack"], "x-prompt": "Which bundler do you want to use to build the application?", - "default": "webpack", + "default": "vite", "x-priority": "important" } }, diff --git a/packages/react-native/src/generators/storybook-configuration/configuration.ts b/packages/react-native/src/generators/storybook-configuration/configuration.ts index 85606724e7f227..c2df112c5bd899 100644 --- a/packages/react-native/src/generators/storybook-configuration/configuration.ts +++ b/packages/react-native/src/generators/storybook-configuration/configuration.ts @@ -1,6 +1,14 @@ -import { Tree, logger, readNxJson } from '@nx/devkit'; +import { + GeneratorCallback, + Tree, + joinPathFragments, + readNxJson, + readProjectConfiguration, + runTasksInSerial, +} from '@nx/devkit'; import { storybookConfigurationGenerator as reactStorybookConfigurationGenerator } from '@nx/react'; import { StorybookConfigureSchema } from './schema'; +import webConfigurationGenerator from '../web-configuration/web-configuration'; export function storybookConfigurationGenerator( tree: Tree, @@ -12,24 +20,59 @@ export function storybookConfigurationGenerator( }); } -/** - * This would be a direct pass through to @nx/react:storybook-configuration generator. - * @TODO (@xiongemi): remove this generator for v19 - */ export async function storybookConfigurationGeneratorInternal( host: Tree, schema: StorybookConfigureSchema ) { - logger.warn( - `Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.` - ); const nxJson = readNxJson(host); const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false; schema.addPlugin ??= addPluginDefault; - return reactStorybookConfigurationGenerator(host, schema); + const projectConfig = readProjectConfiguration(host, schema.project); + const projectType = + schema.projectType ?? projectConfig.projectType ?? 'library'; + const foundViteConfig = findConfig(host, 'vite.config', projectConfig.root); + const foundWebpackConfig = findConfig( + host, + 'webpack.config', + projectConfig.root + ); + + const tasks: GeneratorCallback[] = []; + if (!foundViteConfig && !foundWebpackConfig) { + const webTask = await webConfigurationGenerator(host, { + ...schema, + bundler: schema.bundler ?? 'vite', + projectType, + skipFormat: true, + }); + tasks.push(webTask); + } + + tasks.push(await reactStorybookConfigurationGenerator(host, schema)); + + return runTasksInSerial(...tasks); +} + +export function findConfig( + tree: Tree, + configFileName: string, + projectRoot: string +): boolean { + const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts']; + + for (const ext of allowsExt) { + const configPath = joinPathFragments( + projectRoot, + `${configFileName}.${ext}` + ); + if (tree.exists(configPath)) { + return true; + } + } + return false; } export default storybookConfigurationGenerator; diff --git a/packages/react-native/src/generators/storybook-configuration/schema.d.ts b/packages/react-native/src/generators/storybook-configuration/schema.d.ts index 5095c16b5a9cc4..7c68901916985a 100644 --- a/packages/react-native/src/generators/storybook-configuration/schema.d.ts +++ b/packages/react-native/src/generators/storybook-configuration/schema.d.ts @@ -10,4 +10,6 @@ export interface StorybookConfigureSchema { ignorePaths?: string[]; configureStaticServe?: boolean; addPlugin?: boolean; + bundler?: 'webpack' | 'vite'; + projectType?: 'application' | 'library'; } diff --git a/packages/react-native/src/generators/storybook-configuration/schema.json b/packages/react-native/src/generators/storybook-configuration/schema.json index d12db951ea77b6..07e5de252b53a6 100644 --- a/packages/react-native/src/generators/storybook-configuration/schema.json +++ b/packages/react-native/src/generators/storybook-configuration/schema.json @@ -75,5 +75,6 @@ ] } }, - "required": ["project"] + "required": ["project"], + "examplesFile": "../../../docs/storybook-configuration-examples.md" } diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/.babelrc.js.template b/packages/react-native/src/generators/web-configuration/files/app-vite/.babelrc.js.template similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-vite/.babelrc.js.template rename to packages/react-native/src/generators/web-configuration/files/app-vite/.babelrc.js.template diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/index.html__tmpl__ b/packages/react-native/src/generators/web-configuration/files/app-vite/index.html__tmpl__ similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-vite/index.html__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/app-vite/index.html__tmpl__ diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/public/favicon.ico b/packages/react-native/src/generators/web-configuration/files/app-vite/public/favicon.ico similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-vite/public/favicon.ico rename to packages/react-native/src/generators/web-configuration/files/app-vite/public/favicon.ico diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep b/packages/react-native/src/generators/web-configuration/files/app-vite/src/assets/.gitkeep similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep rename to packages/react-native/src/generators/web-configuration/files/app-vite/src/assets/.gitkeep diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ b/packages/react-native/src/generators/web-configuration/files/app-vite/src/main-web.tsx__tmpl__ similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/app-vite/src/main-web.tsx__tmpl__ diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/.babelrc.js.template b/packages/react-native/src/generators/web-configuration/files/app-webpack/.babelrc.js.template similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/.babelrc.js.template rename to packages/react-native/src/generators/web-configuration/files/app-webpack/.babelrc.js.template diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep b/packages/react-native/src/generators/web-configuration/files/app-webpack/src/assets/.gitkeep similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep rename to packages/react-native/src/generators/web-configuration/files/app-webpack/src/assets/.gitkeep diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/src/favicon.ico b/packages/react-native/src/generators/web-configuration/files/app-webpack/src/favicon.ico similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/src/favicon.ico rename to packages/react-native/src/generators/web-configuration/files/app-webpack/src/favicon.ico diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ b/packages/react-native/src/generators/web-configuration/files/app-webpack/src/index.html__tmpl__ similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/app-webpack/src/index.html__tmpl__ diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ b/packages/react-native/src/generators/web-configuration/files/app-webpack/src/main-web.tsx__tmpl__ similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/app-webpack/src/main-web.tsx__tmpl__ diff --git a/packages/react-native/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ b/packages/react-native/src/generators/web-configuration/files/vite-config/vite.config.ts__tmpl__ similarity index 91% rename from packages/react-native/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/vite-config/vite.config.ts__tmpl__ index 1514782bd9dee9..593618823ab24a 100644 --- a/packages/react-native/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +++ b/packages/react-native/src/generators/web-configuration/files/vite-config/vite.config.ts__tmpl__ @@ -30,7 +30,7 @@ const rollupPlugin = (matchers: RegExp[]) => ({ export default defineConfig({ root: __dirname, - cacheDir: '../../node_modules/.vite/<%= fileName %>', + cacheDir: '<%= offsetFromRoot %>/node_modules/.vite/<%= projectRoot %>', define: { global: 'window', }, @@ -43,7 +43,7 @@ export default defineConfig({ build: { reportCompressedSize: true, commonjsOptions: { transformMixedEsModules: true }, - outDir: '../../dist/apps/<%= fileName %>/web', + outDir: '<%= offsetFromRoot %>/dist/<%= projectRoot %>/web', rollupOptions: { plugins: [rollupPlugin([/react-native-vector-icons/])], }, diff --git a/packages/react-native/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ b/packages/react-native/src/generators/web-configuration/files/webpack-config/webpack.config.js__tmpl__ similarity index 100% rename from packages/react-native/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ rename to packages/react-native/src/generators/web-configuration/files/webpack-config/webpack.config.js__tmpl__ diff --git a/packages/react-native/src/generators/web-configuration/lib/normalize-schema.ts b/packages/react-native/src/generators/web-configuration/lib/normalize-schema.ts index 549972388d3276..04c7c02139e6a2 100644 --- a/packages/react-native/src/generators/web-configuration/lib/normalize-schema.ts +++ b/packages/react-native/src/generators/web-configuration/lib/normalize-schema.ts @@ -1,4 +1,10 @@ -import { Tree, getProjects, names, offsetFromRoot } from '@nx/devkit'; +import { + ProjectConfiguration, + Tree, + getProjects, + names, + offsetFromRoot, +} from '@nx/devkit'; import { WebConfigurationGeneratorSchema } from '../schema'; export interface NormalizedSchema extends WebConfigurationGeneratorSchema { @@ -8,16 +14,18 @@ export interface NormalizedSchema extends WebConfigurationGeneratorSchema { } export function normalizeSchema( - tree: Tree, - schema: WebConfigurationGeneratorSchema + schema: WebConfigurationGeneratorSchema, + projectConfig: ProjectConfiguration ) { - const project = getProjects(tree).get(schema.project); const { fileName, className } = names(schema.project); + const projectType = + schema.projectType ?? projectConfig.projectType ?? 'library'; return { ...schema, - projectRoot: project.root, - offsetFromRoot: offsetFromRoot(project.root), + projectRoot: projectConfig.root, + offsetFromRoot: offsetFromRoot(projectConfig.root), fileName, className, + projectType, }; } diff --git a/packages/react-native/src/generators/web-configuration/schema.d.ts b/packages/react-native/src/generators/web-configuration/schema.d.ts index 7ad1fbcd162e21..3ef18d735754fb 100644 --- a/packages/react-native/src/generators/web-configuration/schema.d.ts +++ b/packages/react-native/src/generators/web-configuration/schema.d.ts @@ -3,4 +3,6 @@ export interface WebConfigurationGeneratorSchema { bundler: 'vite' | 'webpack'; skipFormat?: boolean; skipPackageJson?: boolean; //default is false + projectType?: 'application' | 'library'; + addPlugin?: boolean; } diff --git a/packages/react-native/src/generators/web-configuration/schema.json b/packages/react-native/src/generators/web-configuration/schema.json index a355fef9044b0b..18dc91d089c29e 100644 --- a/packages/react-native/src/generators/web-configuration/schema.json +++ b/packages/react-native/src/generators/web-configuration/schema.json @@ -34,7 +34,7 @@ "type": "string", "enum": ["vite", "webpack"], "x-prompt": "Which bundler do you want to use to build the application?", - "default": "webpack", + "default": "vite", "x-priority": "important" } }, diff --git a/packages/react-native/src/generators/web-configuration/web-configuration.ts b/packages/react-native/src/generators/web-configuration/web-configuration.ts index 4903940df5758c..f75d36c4e5d1a2 100644 --- a/packages/react-native/src/generators/web-configuration/web-configuration.ts +++ b/packages/react-native/src/generators/web-configuration/web-configuration.ts @@ -38,7 +38,8 @@ export async function webConfigurationGenerator( tree: Tree, options: WebConfigurationGeneratorSchema ) { - const normalizedSchema = normalizeSchema(tree, options); + const projectConfig = readProjectConfiguration(tree, options.project); + const normalizedSchema = normalizeSchema(options, projectConfig); const tasks: GeneratorCallback[] = []; @@ -62,14 +63,22 @@ export async function webConfigurationGenerator( if (normalizedSchema.bundler === 'vite') { generateFiles( tree, - joinPathFragments(__dirname, './files/base-vite'), + joinPathFragments(__dirname, './files/vite-config'), normalizedSchema.projectRoot, { ...normalizedSchema, tmpl: '' } ); + if (normalizedSchema.projectType === 'application') { + generateFiles( + tree, + joinPathFragments(__dirname, './files/app-vite'), + normalizedSchema.projectRoot, + { ...normalizedSchema, tmpl: '' } + ); + } } else { generateFiles( tree, - joinPathFragments(__dirname, './files/base-webpack'), + joinPathFragments(__dirname, './files/webpack-config'), normalizedSchema.projectRoot, { ...normalizedSchema, @@ -79,6 +88,20 @@ export async function webConfigurationGenerator( : null, } ); + if (normalizedSchema.projectType === 'application') { + generateFiles( + tree, + joinPathFragments(__dirname, './files/app-webpack'), + normalizedSchema.projectRoot, + { + ...normalizedSchema, + tmpl: '', + webpackPluginOptions: hasWebpackPlugin(tree) + ? createNxWebpackPluginOptions(normalizedSchema) + : null, + } + ); + } } if (!options.skipPackageJson) {