@nx/vite 17.0.0-beta.6 → 17.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/vite",
3
- "version": "17.0.0-beta.6",
3
+ "version": "17.0.0-beta.8",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for building and testing applications using Vite",
6
6
  "repository": {
@@ -32,10 +32,10 @@
32
32
  "@phenomnomnominal/tsquery": "~5.0.1",
33
33
  "@swc/helpers": "~0.5.0",
34
34
  "enquirer": "~2.3.6",
35
- "@nx/devkit": "17.0.0-beta.6",
36
- "@nx/js": "17.0.0-beta.6",
35
+ "@nx/devkit": "17.0.0-beta.8",
36
+ "@nx/js": "17.0.0-beta.8",
37
37
  "tsconfig-paths": "^4.1.2",
38
- "@nrwl/vite": "17.0.0-beta.6"
38
+ "@nrwl/vite": "17.0.0-beta.8"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "vite": "^4.3.4",
@@ -138,27 +138,29 @@ async function viteConfigurationGenerator(tree, schema) {
138
138
  return json;
139
139
  });
140
140
  }
141
- if (schema.uiFramework === 'react') {
142
- (0, _generatorutils.createOrEditViteConfig)(tree, {
143
- project: schema.project,
144
- includeLib: schema.includeLib,
145
- includeVitest: schema.includeVitest,
146
- inSourceTests: schema.inSourceTests,
147
- rollupOptionsExternal: [
148
- `'react'`,
149
- `'react-dom'`,
150
- `'react/jsx-runtime'`
151
- ],
152
- rollupOptionsExternalString: `"'react', 'react-dom', 'react/jsx-runtime'"`,
153
- imports: [
154
- schema.compiler === 'swc' ? `import react from '@vitejs/plugin-react-swc'` : `import react from '@vitejs/plugin-react'`
155
- ],
156
- plugins: [
157
- 'react()'
158
- ]
159
- }, false);
160
- } else {
161
- (0, _generatorutils.createOrEditViteConfig)(tree, schema, false, projectAlreadyHasViteTargets);
141
+ if (!schema.newProject) {
142
+ // We are converting existing project to use Vite
143
+ if (schema.uiFramework === 'react') {
144
+ (0, _generatorutils.createOrEditViteConfig)(tree, {
145
+ project: schema.project,
146
+ includeLib: schema.includeLib,
147
+ includeVitest: schema.includeVitest,
148
+ inSourceTests: schema.inSourceTests,
149
+ rollupOptionsExternal: [
150
+ "'react'",
151
+ "'react-dom'",
152
+ "'react/jsx-runtime'"
153
+ ],
154
+ imports: [
155
+ schema.compiler === 'swc' ? `import react from '@vitejs/plugin-react-swc'` : `import react from '@vitejs/plugin-react'`
156
+ ],
157
+ plugins: [
158
+ 'react()'
159
+ ]
160
+ }, false);
161
+ } else {
162
+ (0, _generatorutils.createOrEditViteConfig)(tree, schema, false, projectAlreadyHasViteTargets);
163
+ }
162
164
  }
163
165
  if (schema.includeVitest) {
164
166
  const vitestTask = await (0, _vitestgenerator.default)(tree, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\n\nimport {\n addOrChangeBuildTarget,\n addOrChangeServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n deleteWebpackConfig,\n editTsConfig,\n findExistingTargetsInProject,\n handleUnknownExecutors,\n handleUnsupportedUserProvidedTargets,\n moveAndEditIndexHtml,\n TargetFlags,\n UserProvidedTargetName,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\n\nexport async function viteConfigurationGenerator(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, projectType, root } = readProjectConfiguration(\n tree,\n schema.project\n );\n let buildTargetName = 'build';\n let serveTargetName = 'serve';\n let testTargetName = 'test';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n const userProvidedTargetName: UserProvidedTargetName = {\n build: schema.buildTarget,\n serve: schema.serveTarget,\n test: schema.testTarget,\n };\n\n const {\n validFoundTargetName,\n projectContainsUnsupportedExecutor,\n userProvidedTargetIsUnsupported,\n alreadyHasNxViteTargets,\n } = findExistingTargetsInProject(targets, userProvidedTargetName);\n projectAlreadyHasViteTargets = alreadyHasNxViteTargets;\n /**\n * This means that we only found unsupported build targets in that project.\n * The only way that buildTarget is defined, means that it is supported.\n *\n * If the `unsupported` flag was false, it would mean that we did not find\n * a build target at all, so we can create a new one.\n *\n * So we only throw if we found a target, but it is unsupported.\n */\n if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {\n throw new Error(\n `The project ${schema.project} cannot be converted to use the @nx/vite executors.`\n );\n }\n\n if (\n alreadyHasNxViteTargets.build &&\n (alreadyHasNxViteTargets.serve || projectType === 'library') &&\n alreadyHasNxViteTargets.test\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use the @nx/vite executors.\n Please try a different project, or remove the existing targets \n and re-run this generator to reset the existing Vite Configuration.\n `\n );\n }\n\n /**\n * This means that we did not find any supported executors\n * so we don't have any valid target names.\n *\n * However, the executors that we may have found are not in the\n * list of the specifically unsupported executors either.\n *\n * So, we should warn the user about it.\n */\n\n if (\n !projectContainsUnsupportedExecutor &&\n !validFoundTargetName.build &&\n !validFoundTargetName.serve &&\n !validFoundTargetName.test\n ) {\n await handleUnknownExecutors(schema.project);\n }\n\n /**\n * There is a possibility at this stage that the user has provided\n * targets with unsupported executors.\n * We keep track here of which of the targets that the user provided\n * are unsupported.\n * We do this with the `userProvidedTargetIsUnsupported` object,\n * which contains flags for each target (whether it is supported or not).\n *\n * We also keep track of the targets that we found in the project,\n * through the findExistingTargetsInProject function, which returns\n * targets for build/serve/test that use supported executors, and\n * can be converted to use the vite executors. These are the\n * kept in the validFoundTargetName object.\n */\n await handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported,\n userProvidedTargetName,\n validFoundTargetName\n );\n\n /**\n * Once the user is at this stage, then they can go ahead and convert.\n */\n\n buildTargetName = validFoundTargetName.build ?? buildTargetName;\n serveTargetName = validFoundTargetName.serve ?? serveTargetName;\n\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema, buildTargetName);\n }\n\n deleteWebpackConfig(\n tree,\n root,\n targets?.[buildTargetName]?.options?.webpackConfig\n );\n\n editTsConfig(tree, schema);\n }\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n includeLib: schema.includeLib,\n compiler: schema.compiler,\n testEnvironment: schema.testEnvironment,\n });\n tasks.push(initTask);\n\n if (!projectAlreadyHasViteTargets.build) {\n addOrChangeBuildTarget(tree, schema, buildTargetName);\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addOrChangeServeTarget(tree, schema, serveTargetName);\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, serveTargetName);\n }\n }\n\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(tree, joinPathFragments(root, 'tsconfig.lib.json'), (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n });\n }\n\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n `'react'`,\n `'react-dom'`,\n `'react/jsx-runtime'`,\n ],\n rollupOptionsExternalString: `\"'react', 'react-dom', 'react/jsx-runtime'\"`,\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'c8',\n skipViteConfig: true,\n testTarget: testTargetName,\n skipFormat: true,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","tree","schema","tasks","targets","projectType","root","readProjectConfiguration","project","buildTargetName","serveTargetName","testTargetName","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","userProvidedTargetName","build","buildTarget","serve","serveTarget","test","testTarget","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","findExistingTargetsInProject","Error","handleUnknownExecutors","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","deleteWebpackConfig","options","webpackConfig","editTsConfig","initTask","initGenerator","uiFramework","compiler","push","addOrChangeBuildTarget","addOrChangeServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","rollupOptionsExternalString","imports","plugins","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IA6BsBA,0BAA0B;eAA1BA;;IAyNtB,OAA0C;eAA1C;;;;wBA9OO;gCAeA;sBAEmB;iCACE;AAGrB,eAAeA,2BACpBC,IAAU,EACVC,MAAwC;QAYxCA,SAEA,8EAA8E;IAC9E,8EAA8E;IAC9EA;IAdA,M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,wBAAgB,KAAI7D;AAC7B;MAEA,WAAeH"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\n\nimport {\n addOrChangeBuildTarget,\n addOrChangeServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n deleteWebpackConfig,\n editTsConfig,\n findExistingTargetsInProject,\n handleUnknownExecutors,\n handleUnsupportedUserProvidedTargets,\n moveAndEditIndexHtml,\n TargetFlags,\n UserProvidedTargetName,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\n\nexport async function viteConfigurationGenerator(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, projectType, root } = readProjectConfiguration(\n tree,\n schema.project\n );\n let buildTargetName = 'build';\n let serveTargetName = 'serve';\n let testTargetName = 'test';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n const userProvidedTargetName: UserProvidedTargetName = {\n build: schema.buildTarget,\n serve: schema.serveTarget,\n test: schema.testTarget,\n };\n\n const {\n validFoundTargetName,\n projectContainsUnsupportedExecutor,\n userProvidedTargetIsUnsupported,\n alreadyHasNxViteTargets,\n } = findExistingTargetsInProject(targets, userProvidedTargetName);\n projectAlreadyHasViteTargets = alreadyHasNxViteTargets;\n /**\n * This means that we only found unsupported build targets in that project.\n * The only way that buildTarget is defined, means that it is supported.\n *\n * If the `unsupported` flag was false, it would mean that we did not find\n * a build target at all, so we can create a new one.\n *\n * So we only throw if we found a target, but it is unsupported.\n */\n if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {\n throw new Error(\n `The project ${schema.project} cannot be converted to use the @nx/vite executors.`\n );\n }\n\n if (\n alreadyHasNxViteTargets.build &&\n (alreadyHasNxViteTargets.serve || projectType === 'library') &&\n alreadyHasNxViteTargets.test\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use the @nx/vite executors.\n Please try a different project, or remove the existing targets \n and re-run this generator to reset the existing Vite Configuration.\n `\n );\n }\n\n /**\n * This means that we did not find any supported executors\n * so we don't have any valid target names.\n *\n * However, the executors that we may have found are not in the\n * list of the specifically unsupported executors either.\n *\n * So, we should warn the user about it.\n */\n\n if (\n !projectContainsUnsupportedExecutor &&\n !validFoundTargetName.build &&\n !validFoundTargetName.serve &&\n !validFoundTargetName.test\n ) {\n await handleUnknownExecutors(schema.project);\n }\n\n /**\n * There is a possibility at this stage that the user has provided\n * targets with unsupported executors.\n * We keep track here of which of the targets that the user provided\n * are unsupported.\n * We do this with the `userProvidedTargetIsUnsupported` object,\n * which contains flags for each target (whether it is supported or not).\n *\n * We also keep track of the targets that we found in the project,\n * through the findExistingTargetsInProject function, which returns\n * targets for build/serve/test that use supported executors, and\n * can be converted to use the vite executors. These are the\n * kept in the validFoundTargetName object.\n */\n await handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported,\n userProvidedTargetName,\n validFoundTargetName\n );\n\n /**\n * Once the user is at this stage, then they can go ahead and convert.\n */\n\n buildTargetName = validFoundTargetName.build ?? buildTargetName;\n serveTargetName = validFoundTargetName.serve ?? serveTargetName;\n\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema, buildTargetName);\n }\n\n deleteWebpackConfig(\n tree,\n root,\n targets?.[buildTargetName]?.options?.webpackConfig\n );\n\n editTsConfig(tree, schema);\n }\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n includeLib: schema.includeLib,\n compiler: schema.compiler,\n testEnvironment: schema.testEnvironment,\n });\n tasks.push(initTask);\n\n if (!projectAlreadyHasViteTargets.build) {\n addOrChangeBuildTarget(tree, schema, buildTargetName);\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addOrChangeServeTarget(tree, schema, serveTargetName);\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, serveTargetName);\n }\n }\n\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(tree, joinPathFragments(root, 'tsconfig.lib.json'), (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n });\n }\n\n if (!schema.newProject) {\n // We are converting existing project to use Vite\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'c8',\n skipViteConfig: true,\n testTarget: testTargetName,\n skipFormat: true,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","tree","schema","tasks","targets","projectType","root","readProjectConfiguration","project","buildTargetName","serveTargetName","testTargetName","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","userProvidedTargetName","build","buildTarget","serve","serveTarget","test","testTarget","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","findExistingTargetsInProject","Error","handleUnknownExecutors","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","deleteWebpackConfig","options","webpackConfig","editTsConfig","initTask","initGenerator","uiFramework","compiler","push","addOrChangeBuildTarget","addOrChangeServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","imports","plugins","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IA6BsBA,0BAA0B;eAA1BA;;IA2NtB,OAA0C;eAA1C;;;;wBAhPO;gCAeA;sBAEmB;iCACE;AAGrB,eAAeA,2BACpBC,IAAU,EACVC,MAAwC;QAYxCA,SAEA,8EAA8E;IAC9E,8EAA8E;IAC9EA;IAdA,MAAMC,QAA6B,EAAE;IAErC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,IAAI,EAAE,GAAGC,IAAAA,gCAAwB,EAC7DN,MACAC,OAAOM,OAAO;IAEhB,IAAIC,kBAAkB;IACtB,IAAIC,kBAAkB;IACtB,IAAIC,iBAAiB;;IAErBT,gBAAAA,UAAAA,QAAOU,oCAAPV,QAAOU,aAAeP,gBAAgB;;IAItCH,qBAAAA,WAAAA,QAAOW,8CAAPX,SAAOW,kBAAoB;IAE3B;;;GAGC,GACD,IAAIC,+BAA4C,CAAC;IAEjD,IAAI,CAACZ,OAAOa,UAAU,EAAE;YA+FpBX,kCAAAA;QA9FF,MAAMY,yBAAiD;YACrDC,OAAOf,OAAOgB,WAAW;YACzBC,OAAOjB,OAAOkB,WAAW;YACzBC,MAAM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C7BwC,eAAelD,OAAOkD,aAAa;gBACnCC,eAAenD,OAAOmD,aAAa;gBACnCC,uBAAuB;oBACrB;oBACA;oBACA;iBACD;gBACDC,SAAS;oBACPrD,OAAOqC,QAAQ,KAAK,QAChB,CAAC,4CAA4C,CAAC,GAC9C,CAAC,wCAAwC,CAAC;iBAC/C;gBACDiB,SAAS;oBAAC;iBAAU;YACtB,GACA;QAEJ,OAAO;YACLL,IAAAA,sCAAsB,EAAClD,MAAMC,QAAQ,OAAOY;QAC9C;IACF;IAEA,IAAIZ,OAAOkD,aAAa,EAAE;QACxB,MAAMK,aAAa,MAAMC,IAAAA,wBAAe,EAACzD,MAAM;YAC7CO,SAASN,OAAOM,OAAO;YACvB8B,aAAapC,OAAOoC,WAAW;YAC/Be,eAAenD,OAAOmD,aAAa;YACnCM,kBAAkB;YAClBC,gBAAgB;YAChBtC,YAAYX;YACZkD,YAAY;QACd;QACA1D,MAAMqC,IAAI,CAACiB;IACb;IAEA,IAAI,CAACvD,OAAO2D,UAAU,EAAE;QACtB,MAAMC,IAAAA,mBAAW,EAAC7D;IACpB;IAEA,OAAO8D,IAAAA,wBAAgB,KAAI5D;AAC7B;MAEA,WAAeH"}
@@ -39,11 +39,10 @@ async function vitestGenerator(tree, schema) {
39
39
  includeVitest: true,
40
40
  inSourceTests: schema.inSourceTests,
41
41
  rollupOptionsExternal: [
42
- `'react'`,
43
- `'react-dom'`,
44
- `'react/jsx-runtime'`
42
+ "'react'",
43
+ "'react-dom'",
44
+ "'react/jsx-runtime'"
45
45
  ],
46
- rollupOptionsExternalString: `"'react', 'react-dom', 'react/jsx-runtime'"`,
47
46
  imports: [
48
47
  `import react from '@vitejs/plugin-react'`
49
48
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/generators/vitest/vitest-generator.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n GeneratorCallback,\n joinPathFragments,\n offsetFromRoot,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport {\n addOrChangeTestTarget,\n createOrEditViteConfig,\n findExistingTargetsInProject,\n} from '../../utils/generator-utils';\nimport { VitestGeneratorSchema } from './schema';\n\nimport initGenerator from '../init/init';\nimport {\n vitestCoverageC8Version,\n vitestCoverageIstanbulVersion,\n vitestCoverageV8Version,\n} from '../../utils/versions';\n\nimport { addTsLibDependencies } from '@nx/js';\nimport { join } from 'path';\n\nexport async function vitestGenerator(\n tree: Tree,\n schema: VitestGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, root, projectType } = readProjectConfiguration(\n tree,\n schema.project\n );\n let testTarget =\n schema.testTarget ??\n findExistingTargetsInProject(targets).validFoundTargetName.test ??\n 'test';\n\n addOrChangeTestTarget(tree, schema, testTarget);\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n testEnvironment: schema.testEnvironment,\n });\n tasks.push(initTask);\n\n if (!schema.skipViteConfig) {\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: projectType === 'library',\n includeVitest: true,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n `'react'`,\n `'react-dom'`,\n `'react/jsx-runtime'`,\n ],\n rollupOptionsExternalString: `\"'react', 'react-dom', 'react/jsx-runtime'\"`,\n imports: [`import react from '@vitejs/plugin-react'`],\n plugins: ['react()'],\n },\n true\n );\n } else {\n createOrEditViteConfig(\n tree,\n {\n ...schema,\n includeVitest: true,\n includeLib: projectType === 'library',\n },\n true\n );\n }\n }\n\n createFiles(tree, schema, root);\n updateTsConfig(tree, schema, root);\n\n const coverageProviderDependency = getCoverageProviderDependency(\n schema.coverageProvider\n );\n\n const installCoverageProviderTask = addDependenciesToPackageJson(\n tree,\n {},\n coverageProviderDependency\n );\n tasks.push(installCoverageProviderTask);\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nfunction updateTsConfig(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n if (tree.exists(joinPathFragments(projectRoot, 'tsconfig.spec.json'))) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.spec.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (\n json.references &&\n !json.references.some((r) => r.path === './tsconfig.spec.json')\n ) {\n json.references.push({\n path: './tsconfig.spec.json',\n });\n }\n return json;\n }\n );\n } else {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n }\n\n if (options.inSourceTests) {\n const tsconfigLibPath = joinPathFragments(projectRoot, 'tsconfig.lib.json');\n const tsconfigAppPath = joinPathFragments(projectRoot, 'tsconfig.app.json');\n if (tree.exists(tsconfigLibPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n } else if (tree.exists(tsconfigAppPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.app.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n }\n\n addTsLibDependencies(tree);\n }\n}\n\nfunction createFiles(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n generateFiles(tree, join(__dirname, 'files'), projectRoot, {\n tmpl: '',\n ...options,\n projectRoot,\n offsetFromRoot: offsetFromRoot(projectRoot),\n });\n}\n\nfunction getCoverageProviderDependency(\n coverageProvider: VitestGeneratorSchema['coverageProvider']\n) {\n switch (coverageProvider) {\n case 'c8':\n return {\n '@vitest/coverage-c8': vitestCoverageC8Version,\n };\n case 'istanbul':\n return {\n '@vitest/coverage-istanbul': vitestCoverageIstanbulVersion,\n };\n default:\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n }\n}\n\nexport default vitestGenerator;\n"],"names":["vitestGenerator","tree","schema","tasks","targets","root","projectType","readProjectConfiguration","project","testTarget","findExistingTargetsInProject","validFoundTargetName","test","addOrChangeTestTarget","initTask","initGenerator","uiFramework","testEnvironment","push","skipViteConfig","createOrEditViteConfig","includeLib","includeVitest","inSourceTests","rollupOptionsExternal","rollupOptionsExternalString","imports","plugins","createFiles","updateTsConfig","coverageProviderDependency","getCoverageProviderDependency","coverageProvider","installCoverageProviderTask","addDependenciesToPackageJson","skipFormat","formatFiles","runTasksInSerial","options","projectRoot","exists","joinPathFragments","updateJson","json","compilerOptions","types","includes","references","some","r","path","tsconfigLibPath","tsconfigAppPath","addTsLibDependencies","generateFiles","join","__dirname","tmpl","offsetFromRoot","vitestCoverageC8Version","vitestCoverageIstanbulVersion","vitestCoverageV8Version"],"mappings":";;;;;;;;IA6BsBA,eAAe;eAAfA;;IA+LtB,OAA+B;eAA/B;;;;wBAjNO;gCAKA;sBAGmB;0BAKnB;oBAE8B;sBAChB;AAEd,eAAeA,gBACpBC,IAAU,EACVC,MAA6B;IAE7B,MAAMC,QAA6B,EAAE;IAErC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,IAAAA,gCAAwB,EAC7DN,MACAC,OAAOM,OAAO;QAGdN,oBAAAA;IADF,IAAIO,aACFP,CAAAA,OAAAA,CAAAA,qBAAAA,OAAOO,UAAU,YAAjBP,qBACAQ,IAAAA,4CAA4B,EAACN,SAASO,oBAAoB,CAACC,IAAI,YAD/DV,OAEA;IAEF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C;YACF;YACA,OAAOF;QACT;IAEJ;IAEA,IAAIL,QAAQf,aAAa,EAAE;QACzB,MAAM4B,kBAAkBV,IAAAA,yBAAiB,EAACF,aAAa;QACvD,MAAMa,kBAAkBX,IAAAA,yBAAiB,EAACF,aAAa;QACvD,IAAItC,KAAKuC,MAAM,CAACW,kBAAkB;YAChCT,IAAAA,kBAAU,EACRzC,MACAwC,IAAAA,yBAAiB,EAACF,aAAa,sBAC/B,CAACI;oBACEA;;gBAAAA,CAAAA,WAAAA,wBAAAA,KAAKC,eAAe,EAACC,0BAArBF,sBAAqBE,QAAU,EAAE,AAAD,EAAG3B,IAAI,CAAC;gBACzC,OAAOyB;YACT;QAEJ,OAAO,IAAI1C,KAAKuC,MAAM,CAACY,kBAAkB;YACvCV,IAAAA,kBAAU,EACRzC,MACAwC,IAAAA,yBAAiB,EAACF,aAAa,sBAC/B,CAACI;oBACEA;;gBAAAA,CAAAA,WAAAA,wBAAAA,KAAKC,eAAe,EAACC,0BAArBF,sBAAqBE,QAAU,EAAE,AAAD,EAAG3B,IAAI,CAAC;gBACzC,OAAOyB;YACT;QAEJ;QAEAU,IAAAA,wBAAoB,EAACpD;IACvB;AACF;AAEA,SAAS2B,YACP3B,IAAU,EACVqC,OAA8B,EAC9BC,WAAmB;IAEnBe,IAAAA,qBAAa,EAACrD,MAAMsD,IAAAA,UAAI,EAACC,WAAW,UAAUjB,aAAa;QACzDkB,MAAM;OACHnB;QACHC;QACAmB,gBAAgBA,IAAAA,sBAAc,EAACnB;;AAEnC;AAEA,SAASR,8BACPC,gBAA2D;IAE3D,OAAQA;QACN,KAAK;YACH,OAAO;gBACL,uBAAuB2B,iCAAuB;YAChD;QACF,KAAK;YACH,OAAO;gBACL,6BAA6BC,uCAA6B;YAC5D;QACF;YACE,OAAO;gBACL,uBAAuBC,iCAAuB;YAChD;IACJ;AACF;MAEA,WAAe7D"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/generators/vitest/vitest-generator.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n GeneratorCallback,\n joinPathFragments,\n offsetFromRoot,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport {\n addOrChangeTestTarget,\n createOrEditViteConfig,\n findExistingTargetsInProject,\n} from '../../utils/generator-utils';\nimport { VitestGeneratorSchema } from './schema';\n\nimport initGenerator from '../init/init';\nimport {\n vitestCoverageC8Version,\n vitestCoverageIstanbulVersion,\n vitestCoverageV8Version,\n} from '../../utils/versions';\n\nimport { addTsLibDependencies } from '@nx/js';\nimport { join } from 'path';\n\nexport async function vitestGenerator(\n tree: Tree,\n schema: VitestGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, root, projectType } = readProjectConfiguration(\n tree,\n schema.project\n );\n let testTarget =\n schema.testTarget ??\n findExistingTargetsInProject(targets).validFoundTargetName.test ??\n 'test';\n\n addOrChangeTestTarget(tree, schema, testTarget);\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n testEnvironment: schema.testEnvironment,\n });\n tasks.push(initTask);\n\n if (!schema.skipViteConfig) {\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: projectType === 'library',\n includeVitest: true,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [`import react from '@vitejs/plugin-react'`],\n plugins: ['react()'],\n },\n true\n );\n } else {\n createOrEditViteConfig(\n tree,\n {\n ...schema,\n includeVitest: true,\n includeLib: projectType === 'library',\n },\n true\n );\n }\n }\n\n createFiles(tree, schema, root);\n updateTsConfig(tree, schema, root);\n\n const coverageProviderDependency = getCoverageProviderDependency(\n schema.coverageProvider\n );\n\n const installCoverageProviderTask = addDependenciesToPackageJson(\n tree,\n {},\n coverageProviderDependency\n );\n tasks.push(installCoverageProviderTask);\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nfunction updateTsConfig(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n if (tree.exists(joinPathFragments(projectRoot, 'tsconfig.spec.json'))) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.spec.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (\n json.references &&\n !json.references.some((r) => r.path === './tsconfig.spec.json')\n ) {\n json.references.push({\n path: './tsconfig.spec.json',\n });\n }\n return json;\n }\n );\n } else {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n }\n\n if (options.inSourceTests) {\n const tsconfigLibPath = joinPathFragments(projectRoot, 'tsconfig.lib.json');\n const tsconfigAppPath = joinPathFragments(projectRoot, 'tsconfig.app.json');\n if (tree.exists(tsconfigLibPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n } else if (tree.exists(tsconfigAppPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.app.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n }\n\n addTsLibDependencies(tree);\n }\n}\n\nfunction createFiles(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n generateFiles(tree, join(__dirname, 'files'), projectRoot, {\n tmpl: '',\n ...options,\n projectRoot,\n offsetFromRoot: offsetFromRoot(projectRoot),\n });\n}\n\nfunction getCoverageProviderDependency(\n coverageProvider: VitestGeneratorSchema['coverageProvider']\n) {\n switch (coverageProvider) {\n case 'c8':\n return {\n '@vitest/coverage-c8': vitestCoverageC8Version,\n };\n case 'istanbul':\n return {\n '@vitest/coverage-istanbul': vitestCoverageIstanbulVersion,\n };\n default:\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n }\n}\n\nexport default vitestGenerator;\n"],"names":["vitestGenerator","tree","schema","tasks","targets","root","projectType","readProjectConfiguration","project","testTarget","findExistingTargetsInProject","validFoundTargetName","test","addOrChangeTestTarget","initTask","initGenerator","uiFramework","testEnvironment","push","skipViteConfig","createOrEditViteConfig","includeLib","includeVitest","inSourceTests","rollupOptionsExternal","imports","plugins","createFiles","updateTsConfig","coverageProviderDependency","getCoverageProviderDependency","coverageProvider","installCoverageProviderTask","addDependenciesToPackageJson","skipFormat","formatFiles","runTasksInSerial","options","projectRoot","exists","joinPathFragments","updateJson","json","compilerOptions","types","includes","references","some","r","path","tsconfigLibPath","tsconfigAppPath","addTsLibDependencies","generateFiles","join","__dirname","tmpl","offsetFromRoot","vitestCoverageC8Version","vitestCoverageIstanbulVersion","vitestCoverageV8Version"],"mappings":";;;;;;;;IA6BsBA,eAAe;eAAfA;;IA8LtB,OAA+B;eAA/B;;;;wBAhNO;gCAKA;sBAGmB;0BAKnB;oBAE8B;sBAChB;AAEd,eAAeA,gBACpBC,IAAU,EACVC,MAA6B;IAE7B,MAAMC,QAA6B,EAAE;IAErC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,IAAAA,gCAAwB,EAC7DN,MACAC,OAAOM,OAAO;QAGdN,oBAAAA;IADF,IAAIO,aACFP,CAAAA,OAAAA,CAAAA,qBAAAA,OAAOO,UAAU,YAAjBP,qBACAQ,IAAAA,4CAA4B,EAACN,SAASO,oBAAo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;QACzB,MAAM2B,kBAAkBV,IAAAA,yBAAiB,EAACF,aAAa;QACvD,MAAMa,kBAAkBX,IAAAA,yBAAiB,EAACF,aAAa;QACvD,IAAIrC,KAAKsC,MAAM,CAACW,kBAAkB;YAChCT,IAAAA,kBAAU,EACRxC,MACAuC,IAAAA,yBAAiB,EAACF,aAAa,sBAC/B,CAACI;oBACEA;;gBAAAA,CAAAA,WAAAA,wBAAAA,KAAKC,eAAe,EAACC,0BAArBF,sBAAqBE,QAAU,EAAE,AAAD,EAAG1B,IAAI,CAAC;gBACzC,OAAOwB;YACT;QAEJ,OAAO,IAAIzC,KAAKsC,MAAM,CAACY,kBAAkB;YACvCV,IAAAA,kBAAU,EACRxC,MACAuC,IAAAA,yBAAiB,EAACF,aAAa,sBAC/B,CAACI;oBACEA;;gBAAAA,CAAAA,WAAAA,wBAAAA,KAAKC,eAAe,EAACC,0BAArBF,sBAAqBE,QAAU,EAAE,AAAD,EAAG1B,IAAI,CAAC;gBACzC,OAAOwB;YACT;QAEJ;QAEAU,IAAAA,wBAAoB,EAACnD;IACvB;AACF;AAEA,SAAS0B,YACP1B,IAAU,EACVoC,OAA8B,EAC9BC,WAAmB;IAEnBe,IAAAA,qBAAa,EAACpD,MAAMqD,IAAAA,UAAI,EAACC,WAAW,UAAUjB,aAAa;QACzDkB,MAAM;OACHnB;QACHC;QACAmB,gBAAgBA,IAAAA,sBAAc,EAACnB;;AAEnC;AAEA,SAASR,8BACPC,gBAA2D;IAE3D,OAAQA;QACN,KAAK;YACH,OAAO;gBACL,uBAAuB2B,iCAAuB;YAChD;QACF,KAAK;YACH,OAAO;gBACL,6BAA6BC,uCAA6B;YAC5D;QACF;YACE,OAAO;gBACL,uBAAuBC,iCAAuB;YAChD;IACJ;AACF;MAEA,WAAe5D"}
@@ -33,7 +33,6 @@ export interface ViteConfigFileOptions {
33
33
  includeVitest?: boolean;
34
34
  inSourceTests?: boolean;
35
35
  testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
36
- rollupOptionsExternalString?: string;
37
36
  rollupOptionsExternal?: string[];
38
37
  imports?: string[];
39
38
  plugins?: string[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const coveragePath = joinPathFragments(\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n passWithNoTests: true,\n // vitest runs in the project root so we have to offset to the workspaceRoot\n reportsDirectory: joinPathFragments(\n offsetFromRoot(project.root),\n coveragePath\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n project.targets[target].executor = '@nx/vite:test';\n delete project.targets[target].options?.jestConfig;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:test',\n outputs: ['{options.reportsDirectory}'],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions.base = project.targets[target].options?.baseHref;\n buildOptions.sourcemap = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n https: project.targets[target].options?.https,\n hmr: project.targets[target].options?.hmr,\n open: project.targets[target].options?.open,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions.https = target.options?.https;\n previewOptions.open = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type='module' src='${mainPath}'></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type='module' src='${mainPath}'></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang='en'>\n <head>\n <meta charset='UTF-8' />\n <link rel='icon' href='/favicon.ico' />\n <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n <title>Vite</title>\n </head>\n <body>\n <div id='root'></div>\n <script type='module' src='${mainPath}'></script>\n </body>\n </html>`\n );\n }\n}\n\nexport interface ViteConfigFileOptions {\n project: string;\n includeLib?: boolean;\n includeVitest?: boolean;\n inSourceTests?: boolean;\n testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;\n rollupOptionsExternalString?: string;\n rollupOptionsExternal?: string[];\n imports?: string[];\n plugins?: string[];\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigFileOptions,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = `${projectConfig.root}/vite.config.ts`;\n\n const buildOption = onlyVitest\n ? ''\n : options.includeLib\n ? `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: '${options.project}',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [${options.rollupOptionsExternal ?? ''}]\n }\n },`\n : ``;\n\n const imports: string[] = options.imports ? options.imports : [];\n\n if (!onlyVitest && options.includeLib) {\n imports.push(\n `import dts from 'vite-plugin-dts'`,\n `import * as path from 'path'`\n );\n }\n\n let viteConfigContent = '';\n\n const plugins = options.plugins\n ? [...options.plugins, `nxViteTsPaths()`]\n : [`nxViteTsPaths()`];\n\n if (!onlyVitest && options.includeLib) {\n plugins.push(\n `dts({ entryRoot: 'src', tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true })`\n );\n }\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectConfig.root)}node_modules/.vitest'\n },\n environment: '${options.testEnvironment ?? 'jsdom'}',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n ${\n options.inSourceTests\n ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']`\n : ''\n }\n },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const devServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n server:{\n port: 4200,\n host: 'localhost',\n },`;\n\n const previewServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n preview:{\n port: 4300,\n host: 'localhost',\n },`;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [ nxViteTsPaths() ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectConfig.root\n )}node_modules/.vite/${options.project}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n imports,\n plugins,\n testOption,\n cacheDir,\n offsetFromRoot(projectConfig.root),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types='vitest' />\n import { defineConfig } from 'vite';\n ${imports.join(';\\n')}${imports.length ? ';' : ''}\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n \n export default defineConfig({\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n \n plugins: [${plugins.join(',\\n')}],\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigFileOptions,\n buildOption: string,\n imports: string[],\n plugins: string[],\n testOption: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (\n projectAlreadyHasViteTargets?.build &&\n projectAlreadyHasViteTargets?.test\n ) {\n return;\n }\n\n if (process.env.NX_VERBOSE_LOGGING === 'true') {\n logger.info(\n `vite.config.ts already exists for project ${options.project}.`\n );\n }\n\n const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: options.rollupOptionsExternal ?? [],\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n imports,\n plugins,\n testOption,\n testOptionObject,\n cacheDir,\n projectAlreadyHasViteTargets ?? {}\n );\n\n if (!changed) {\n logger.warn(\n `Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):\n \n ${buildOption}\n \n `\n );\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","coveragePath","joinPathFragments","root","testOptions","passWithNoTests","reportsDirectory","offsetFromRoot","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","base","baseHref","sourcemap","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","https","hmr","open","proxyConfig","previewOptions","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","viteConfigPath","buildOption","includeLib","rollupOptionsExternal","imports","push","viteConfigContent","plugins","testOption","includeVitest","testEnvironment","inSourceTests","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_VERBOSE_LOGGING","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","testOptionObject","globals","cache","dir","environment","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAoCAC,sBAAsB;eAAtBA;;IA6CAC,sBAAsB;eAAtBA;;IAqDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA+EAC,sBAAsB;eAAtBA;;IA+IAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,sBAAsB;eAAtBA;;;;wBAttBf;qCAMmC;AAOnC,SAASZ,6BACda,OAEC,EACDC,mBAA4C;IAO5C,MAAMC,SAA0D;QAC9DC,sBAAsB,CAAC;QACvBC,oCAAoC;QACpCC,iCAAiC,CAAC;QAClCC,yBAAyB,CAAC;IAC5B;IAEA,MAAMC,qBAAqB;QACzBC,OAAO;YACL;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,OAAO;YACL;YACA;YACA;SACD;QACDC,MAAM;YAAC;YAAiB;YAAmB;SAAuB;IACpE;IAEA,MAAMC,uBAAuB;QAC3B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,oDAAoD;IACpD,0EAA0E;IAC1E,kFAAkF;IAElF,SAASC,wBAAwBC,MAAc;QAC7C,IAAIZ,uCAAAA,mBAAqB,CAACY,OAAO,EAAE;gBAG7Bb;YAFJ,IACEO,kBAAkB,CAACM,OAAO,CAACC,QAAQ,EACjCd,sCAAAA,OAAO,CAACC,mBAAmB,CAACY,OAAO,CAAC,qBAApCb,oCAAsCe,QAAQ,GAEhD;gBACAb,OAAOC,oBAAoB,CAACU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IAEA,IAAI4H,QAAQC,GAAG,CAACC,kBAAkB,KAAK,QAAQ;QAC7Cb,cAAM,CAACc,IAAI,CACT,CAAC,0CAA0C,EAAEpH,QAAQC,OAAO,CAAC,CAAC,CAAC;IAEnE;QAUcD;IARd,MAAMqH,oBAAoB;QACxBtE,KAAK;YACHuE,OAAO;YACPX,MAAM3G,QAAQC,OAAO;YACrBsH,UAAU;YACVC,SAAS;gBAAC;gBAAM;aAAM;QACxB;QACAC,eAAe;YACbC,UAAU1H,CAAAA,iCAAAA,QAAQ6E,qBAAqB,YAA7B7E,iCAAiC,EAAE;QAC/C;IACF;IAEA,MAAM2H,mBAAmB;QACvBC,SAAS;QACTC,OAAO;YACLC,KAAK,CAAC,EAAErH,eAAe,oBAAoB,CAAC;QAC9C;QACAsH,aAAa;QACbzE,SAAS;YAAC;SAAuD;IACnE;IAEA,MAAM0E,UAAUC,IAAAA,8CAAyB,EACvClI,MACA2E,gBACAC,aACA0C,mBACAvC,SACAG,SACAC,YACAyC,kBACAjC,UACAjB,uCAAAA,+BAAgC,CAAC;IAGnC,IAAI,CAACuD,SAAS;QACZ1B,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAE7B,eAAe;;QAExF,EAAEC,YAAY;;QAEd,CAAC;IAEP;AACF"}
1
+ {"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const coveragePath = joinPathFragments(\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n passWithNoTests: true,\n // vitest runs in the project root so we have to offset to the workspaceRoot\n reportsDirectory: joinPathFragments(\n offsetFromRoot(project.root),\n coveragePath\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n project.targets[target].executor = '@nx/vite:test';\n delete project.targets[target].options?.jestConfig;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:test',\n outputs: ['{options.reportsDirectory}'],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions.base = project.targets[target].options?.baseHref;\n buildOptions.sourcemap = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n https: project.targets[target].options?.https,\n hmr: project.targets[target].options?.hmr,\n open: project.targets[target].options?.open,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions.https = target.options?.https;\n previewOptions.open = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type='module' src='${mainPath}'></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type='module' src='${mainPath}'></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang='en'>\n <head>\n <meta charset='UTF-8' />\n <link rel='icon' href='/favicon.ico' />\n <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n <title>Vite</title>\n </head>\n <body>\n <div id='root'></div>\n <script type='module' src='${mainPath}'></script>\n </body>\n </html>`\n );\n }\n}\n\nexport interface ViteConfigFileOptions {\n project: string;\n includeLib?: boolean;\n includeVitest?: boolean;\n inSourceTests?: boolean;\n testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;\n rollupOptionsExternal?: string[];\n imports?: string[];\n plugins?: string[];\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigFileOptions,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = `${projectConfig.root}/vite.config.ts`;\n\n const buildOption = onlyVitest\n ? ''\n : options.includeLib\n ? `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: '${options.project}',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [${options.rollupOptionsExternal ?? ''}]\n }\n },`\n : ``;\n\n const imports: string[] = options.imports ? options.imports : [];\n\n if (!onlyVitest && options.includeLib) {\n imports.push(\n `import dts from 'vite-plugin-dts'`,\n `import * as path from 'path'`\n );\n }\n\n let viteConfigContent = '';\n\n const plugins = options.plugins\n ? [...options.plugins, `nxViteTsPaths()`]\n : [`nxViteTsPaths()`];\n\n if (!onlyVitest && options.includeLib) {\n plugins.push(\n `dts({ entryRoot: 'src', tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true })`\n );\n }\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectConfig.root)}node_modules/.vitest'\n },\n environment: '${options.testEnvironment ?? 'jsdom'}',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n ${\n options.inSourceTests\n ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']`\n : ''\n }\n },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const devServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n server:{\n port: 4200,\n host: 'localhost',\n },`;\n\n const previewServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n preview:{\n port: 4300,\n host: 'localhost',\n },`;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [ nxViteTsPaths() ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectConfig.root\n )}node_modules/.vite/${options.project}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n imports,\n plugins,\n testOption,\n cacheDir,\n offsetFromRoot(projectConfig.root),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types='vitest' />\n import { defineConfig } from 'vite';\n ${imports.join(';\\n')}${imports.length ? ';' : ''}\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n \n export default defineConfig({\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n \n plugins: [${plugins.join(',\\n')}],\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigFileOptions,\n buildOption: string,\n imports: string[],\n plugins: string[],\n testOption: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (\n projectAlreadyHasViteTargets?.build &&\n projectAlreadyHasViteTargets?.test\n ) {\n return;\n }\n\n if (process.env.NX_VERBOSE_LOGGING === 'true') {\n logger.info(\n `vite.config.ts already exists for project ${options.project}.`\n );\n }\n\n const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: options.rollupOptionsExternal ?? [],\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n imports,\n plugins,\n testOption,\n testOptionObject,\n cacheDir,\n projectAlreadyHasViteTargets ?? {}\n );\n\n if (!changed) {\n logger.warn(\n `Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):\n \n ${buildOption}\n \n `\n );\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","coveragePath","joinPathFragments","root","testOptions","passWithNoTests","reportsDirectory","offsetFromRoot","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","base","baseHref","sourcemap","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","https","hmr","open","proxyConfig","previewOptions","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","viteConfigPath","buildOption","includeLib","rollupOptionsExternal","imports","push","viteConfigContent","plugins","testOption","includeVitest","testEnvironment","inSourceTests","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_VERBOSE_LOGGING","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","testOptionObject","globals","cache","dir","environment","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAoCAC,sBAAsB;eAAtBA;;IA6CAC,sBAAsB;eAAtBA;;IAqDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA8EAC,sBAAsB;eAAtBA;;IA+IAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,sBAAsB;eAAtBA;;;;wBArtBf;qCAMmC;AAOnC,SAASZ,6BACda,OAEC,EACDC,mBAA4C;IAO5C,MAAMC,SAA0D;QAC9DC,sBAAsB,CAAC;QACvBC,oCAAoC;QACp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yB,EACvClI,MACA2E,gBACAC,aACA0C,mBACAvC,SACAG,SACAC,YACAyC,kBACAjC,UACAjB,uCAAAA,+BAAgC,CAAC;IAGnC,IAAI,CAACuD,SAAS;QACZ1B,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAE7B,eAAe;;QAExF,EAAEC,YAAY;;QAEd,CAAC;IAEP;AACF"}
@@ -6,7 +6,7 @@ export declare const configNoDefineConfig = "\n /// <reference types=\"vitest
6
6
  export declare const noBuildOptionsHasTestOption = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n ";
7
7
  export declare const someBuildOptionsSomeTestOption = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n ";
8
8
  export declare const hasEverything = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n import dts from 'vite-plugin-dts';\n import { joinPathFragments } from '@nx/devkit';\n\n export default defineConfig({\n plugins: [\n dts({ entryRoot: 'src', tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true }),\n react(),\n nxViteTsPaths(),\n ],\n \n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'pure-libs-react-vite',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n },\n \n test: {\n globals: true,\n cache: {\n dir: '../../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n });\n ";
9
- export declare const buildOption = "\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [\"'react', 'react-dom', 'react/jsx-runtime'\"]\n }\n },";
9
+ export declare const buildOption = "\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: ['react', 'react-dom', 'react/jsx-runtime']\n }\n },";
10
10
  export declare const buildOptionObject: {
11
11
  lib: {
12
12
  entry: string;
@@ -240,7 +240,7 @@ const buildOption = `
240
240
  },
241
241
  rollupOptions: {
242
242
  // External packages that should not be bundled into your library.
243
- external: ["'react', 'react-dom', 'react/jsx-runtime'"]
243
+ external: ['react', 'react-dom', 'react/jsx-runtime']
244
244
  }
245
245
  },`;
246
246
  const buildOptionObject = {
@@ -255,7 +255,9 @@ const buildOptionObject = {
255
255
  },
256
256
  rollupOptions: {
257
257
  external: [
258
- "'react', 'react-dom', 'react/jsx-runtime'"
258
+ 'react',
259
+ 'react-dom',
260
+ 'react/jsx-runtime'
259
261
  ]
260
262
  }
261
263
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/utils/test-files/test-vite-configs.ts"],"sourcesContent":["export const noBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const noContentDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({});\n `;\n\nexport const conditionalConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n export default defineConfig(({ command, mode, ssrBuild }) => {\n if (command === 'serve') {\n return {\n port: 4200,\n host: 'localhost',\n }\n } else {\n // command === 'build'\n return {\n my: 'option',\n }\n }\n })\n `;\n\nexport const configNoDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default {\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n };\n `;\n\nexport const noBuildOptionsHasTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptionsSomeTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const hasEverything = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n import dts from 'vite-plugin-dts';\n import { joinPathFragments } from '@nx/devkit';\n\n export default defineConfig({\n plugins: [\n dts({ entryRoot: 'src', tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true }),\n react(),\n nxViteTsPaths(),\n ],\n \n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'pure-libs-react-vite',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n },\n \n test: {\n globals: true,\n cache: {\n dir: '../../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n });\n `;\n\nexport const buildOption = `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [\"'react', 'react-dom', 'react/jsx-runtime'\"]\n }\n },`;\nexport const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: [\"'react', 'react-dom', 'react/jsx-runtime'\"],\n },\n};\n\nexport const testOption = `test: {\n globals: true,\n cache: {\n dir: '../node_modules/.vitest'\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },`;\n\nexport const testOptionObject = {\n globals: true,\n cache: {\n dir: `../node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n};\n\nexport const imports = [\n `import dts from 'vite-plugin-dts'`,\n `import { joinPathFragments } from '@nx/devkit'`,\n];\n\nexport const plugins = [`react()`, `nxViteTsPaths()`];\n"],"names":["noBuildOptions","someBuildOptions","noContentDefineConfig","conditionalConfig","configNoDefineConfig","noBuildOptionsHasTestOption","someBuildOptionsSomeTestOption","hasEverything","buildOption","buildOptionObject","testOption","testOptionObject","imports","plugins","lib","entry","name","fileName","formats","rollupOptions","external","globals","cache","dir","environment","include"],"mappings":";;;;;;;;IAAaA,cAAc;eAAdA;;IAwBAC,gBAAgB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AU;IACrB,CAAC,iCAAiC,CAAC;IACnC,CAAC,8CAA8C,CAAC;CACjD;AAEM,MAAMC,UAAU;IAAC,CAAC,OAAO,CAAC;IAAE,CAAC,eAAe,CAAC;CAAC"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/utils/test-files/test-vite-configs.ts"],"sourcesContent":["export const noBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const noContentDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({});\n `;\n\nexport const conditionalConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n export default defineConfig(({ command, mode, ssrBuild }) => {\n if (command === 'serve') {\n return {\n port: 4200,\n host: 'localhost',\n }\n } else {\n // command === 'build'\n return {\n my: 'option',\n }\n }\n })\n `;\n\nexport const configNoDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default {\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n };\n `;\n\nexport const noBuildOptionsHasTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptionsSomeTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\n export default defineConfig({\n plugins: [\n react(),\n nxViteTsPaths(),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const hasEverything = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n import dts from 'vite-plugin-dts';\n import { joinPathFragments } from '@nx/devkit';\n\n export default defineConfig({\n plugins: [\n dts({ entryRoot: 'src', tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true }),\n react(),\n nxViteTsPaths(),\n ],\n \n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'pure-libs-react-vite',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n },\n \n test: {\n globals: true,\n cache: {\n dir: '../../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n });\n `;\n\nexport const buildOption = `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: ['react', 'react-dom', 'react/jsx-runtime']\n }\n },`;\nexport const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n};\n\nexport const testOption = `test: {\n globals: true,\n cache: {\n dir: '../node_modules/.vitest'\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },`;\n\nexport const testOptionObject = {\n globals: true,\n cache: {\n dir: `../node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n};\n\nexport const imports = [\n `import dts from 'vite-plugin-dts'`,\n `import { joinPathFragments } from '@nx/devkit'`,\n];\n\nexport const plugins = [`react()`, `nxViteTsPaths()`];\n"],"names":["noBuildOptions","someBuildOptions","noContentDefineConfig","conditionalConfig","configNoDefineConfig","noBuildOptionsHasTestOption","someBuildOptionsSomeTestOption","hasEverything","buildOption","buildOptionObject","testOption","testOptionObject","imports","plugins","lib","entry","name","fileName","formats","rollupOptions","external","globals","cache","dir","environment","include"],"mappings":";;;;;;;;IAAaA,cAAc;eAAdA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