@nx/vite 17.0.5 → 17.0.6

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.
Files changed (116) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +3 -3
  4. package/migrations.json +0 -90
  5. package/package.json +7 -9
  6. package/plugins/nx-tsconfig-paths.plugin.js +5 -9
  7. package/plugins/nx-tsconfig-paths.plugin.js.map +1 -1
  8. package/plugins/rollup-replace-files.plugin.d.ts +3 -3
  9. package/plugins/rollup-replace-files.plugin.js +2 -2
  10. package/plugins/rollup-replace-files.plugin.js.map +1 -1
  11. package/src/executors/build/build.impl.d.ts +1 -5
  12. package/src/executors/build/build.impl.js +21 -90
  13. package/src/executors/build/build.impl.js.map +1 -1
  14. package/src/executors/build/schema.d.ts +18 -5
  15. package/src/executors/build/schema.json +106 -4
  16. package/src/executors/dev-server/dev-server.impl.js +9 -74
  17. package/src/executors/dev-server/dev-server.impl.js.map +1 -1
  18. package/src/executors/dev-server/schema.d.ts +10 -0
  19. package/src/executors/dev-server/schema.json +63 -0
  20. package/src/executors/preview-server/preview-server.impl.d.ts +1 -1
  21. package/src/executors/preview-server/preview-server.impl.js +15 -79
  22. package/src/executors/preview-server/preview-server.impl.js.map +1 -1
  23. package/src/executors/preview-server/schema.d.ts +7 -0
  24. package/src/executors/preview-server/schema.json +51 -1
  25. package/src/executors/test/schema.d.ts +8 -3
  26. package/src/executors/test/schema.json +43 -11
  27. package/src/executors/test/vitest.impl.js +112 -20
  28. package/src/executors/test/vitest.impl.js.map +1 -1
  29. package/src/generators/configuration/configuration.d.ts +1 -2
  30. package/src/generators/configuration/configuration.js +87 -49
  31. package/src/generators/configuration/configuration.js.map +1 -1
  32. package/src/generators/configuration/schema.d.ts +3 -1
  33. package/src/generators/configuration/schema.json +12 -0
  34. package/src/generators/init/init.d.ts +3 -4
  35. package/src/generators/init/init.js +67 -50
  36. package/src/generators/init/init.js.map +1 -1
  37. package/src/generators/init/schema.d.ts +5 -5
  38. package/src/generators/init/schema.json +20 -17
  39. package/src/generators/vitest/files/tsconfig.spec.json__tmpl__ +1 -2
  40. package/src/generators/vitest/schema.d.ts +1 -2
  41. package/src/generators/vitest/schema.json +2 -2
  42. package/src/generators/vitest/vitest-generator.d.ts +1 -2
  43. package/src/generators/vitest/vitest-generator.js +10 -34
  44. package/src/generators/vitest/vitest-generator.js.map +1 -1
  45. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js.map +1 -1
  46. package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js +17 -3
  47. package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js.map +1 -1
  48. package/src/utils/executor-utils.d.ts +0 -2
  49. package/src/utils/executor-utils.js +7 -22
  50. package/src/utils/executor-utils.js.map +1 -1
  51. package/src/utils/generator-utils.d.ts +12 -10
  52. package/src/utils/generator-utils.js +213 -134
  53. package/src/utils/generator-utils.js.map +1 -1
  54. package/src/utils/options-utils.d.ts +19 -3
  55. package/src/utils/options-utils.js +68 -25
  56. package/src/utils/options-utils.js.map +1 -1
  57. package/src/utils/test-files/react-lib-non-buildable-jest.json +4 -1
  58. package/src/utils/test-files/react-lib-non-buildable-vitest.json +4 -1
  59. package/src/utils/test-files/react-mixed-project.config.json +6 -1
  60. package/src/utils/test-files/react-project.config.json +85 -0
  61. package/src/utils/test-files/react-vite-project.config.json +4 -1
  62. package/src/utils/test-files/unknown-project.config.json +4 -1
  63. package/src/utils/test-files/web-project.config.json +72 -0
  64. package/src/utils/test-utils.d.ts +1 -1
  65. package/src/utils/test-utils.js +18 -10
  66. package/src/utils/test-utils.js.map +1 -1
  67. package/src/utils/versions.d.ts +9 -7
  68. package/src/utils/versions.js +15 -7
  69. package/src/utils/versions.js.map +1 -1
  70. package/src/utils/vite-config-edit-utils.js +1 -1
  71. package/src/utils/vite-config-edit-utils.js.map +1 -1
  72. package/plugin.d.ts +0 -1
  73. package/plugin.js +0 -21
  74. package/plugin.js.map +0 -1
  75. package/src/executors/test/lib/nx-reporter.d.ts +0 -14
  76. package/src/executors/test/lib/nx-reporter.js +0 -40
  77. package/src/executors/test/lib/nx-reporter.js.map +0 -1
  78. package/src/executors/test/lib/utils.d.ts +0 -4
  79. package/src/executors/test/lib/utils.js +0 -77
  80. package/src/executors/test/lib/utils.js.map +0 -1
  81. package/src/generators/configuration/lib/convert-non-vite.d.ts +0 -5
  82. package/src/generators/configuration/lib/convert-non-vite.js +0 -62
  83. package/src/generators/configuration/lib/convert-non-vite.js.map +0 -1
  84. package/src/generators/init/lib/utils.d.ts +0 -6
  85. package/src/generators/init/lib/utils.js +0 -80
  86. package/src/generators/init/lib/utils.js.map +0 -1
  87. package/src/migrations/update-17-1-0/move-target-defaults.d.ts +0 -2
  88. package/src/migrations/update-17-1-0/move-target-defaults.js +0 -77
  89. package/src/migrations/update-17-1-0/move-target-defaults.js.map +0 -1
  90. package/src/migrations/update-17-2-0/lib/add-file-replacements.d.ts +0 -2
  91. package/src/migrations/update-17-2-0/lib/add-file-replacements.js +0 -67
  92. package/src/migrations/update-17-2-0/lib/add-file-replacements.js.map +0 -1
  93. package/src/migrations/update-17-2-0/lib/edit-build-config.d.ts +0 -2
  94. package/src/migrations/update-17-2-0/lib/edit-build-config.js +0 -121
  95. package/src/migrations/update-17-2-0/lib/edit-build-config.js.map +0 -1
  96. package/src/migrations/update-17-2-0/lib/edit-test-config.d.ts +0 -2
  97. package/src/migrations/update-17-2-0/lib/edit-test-config.js +0 -83
  98. package/src/migrations/update-17-2-0/lib/edit-test-config.js.map +0 -1
  99. package/src/migrations/update-17-2-0/update-vite-config.d.ts +0 -5
  100. package/src/migrations/update-17-2-0/update-vite-config.js +0 -68
  101. package/src/migrations/update-17-2-0/update-vite-config.js.map +0 -1
  102. package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.d.ts +0 -3
  103. package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.js +0 -117
  104. package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.js.map +0 -1
  105. package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.d.ts +0 -2
  106. package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.js +0 -45
  107. package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.js.map +0 -1
  108. package/src/plugins/plugin.d.ts +0 -10
  109. package/src/plugins/plugin.js +0 -226
  110. package/src/plugins/plugin.js.map +0 -1
  111. package/src/utils/ensure-dependencies.d.ts +0 -8
  112. package/src/utils/ensure-dependencies.js +0 -34
  113. package/src/utils/ensure-dependencies.js.map +0 -1
  114. package/src/utils/find-vite-config.d.ts +0 -3
  115. package/src/utils/find-vite-config.js +0 -46
  116. package/src/utils/find-vite-config.js.map +0 -1
@@ -28,11 +28,10 @@
28
28
  "description": "Skip type-checking via TypeScript. Skipping type-checking speeds up the build but type errors are not caught.",
29
29
  "default": false
30
30
  },
31
- "tsConfig": {
31
+ "base": {
32
32
  "type": "string",
33
- "description": "The path to custom tsconfig file for type-checking when skipTypeCheck is false. Required when tsconfig file is not at the projectRoot level.",
34
- "x-completion-type": "file",
35
- "x-completion-glob": "tsconfig.*.json"
33
+ "description": "Base public path when served in development or production.",
34
+ "alias": "baseHref"
36
35
  },
37
36
  "configFile": {
38
37
  "type": "string",
@@ -40,6 +39,109 @@
40
39
  "x-completion-type": "file",
41
40
  "x-completion-glob": "vite.config.@(js|ts)"
42
41
  },
42
+ "fileReplacements": {
43
+ "description": "Replace files with other files in the build.",
44
+ "type": "array",
45
+ "items": {
46
+ "type": "object",
47
+ "properties": {
48
+ "replace": {
49
+ "type": "string",
50
+ "description": "The file to be replaced.",
51
+ "x-completion-type": "file"
52
+ },
53
+ "with": {
54
+ "type": "string",
55
+ "description": "The file to replace with.",
56
+ "x-completion-type": "file"
57
+ }
58
+ },
59
+ "additionalProperties": false,
60
+ "required": ["replace", "with"]
61
+ },
62
+ "default": []
63
+ },
64
+ "emptyOutDir": {
65
+ "description": "When set to false, outputPath will not be emptied during the build process.",
66
+ "type": "boolean",
67
+ "default": true
68
+ },
69
+ "sourcemap": {
70
+ "description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
71
+ "oneOf": [
72
+ {
73
+ "type": "boolean"
74
+ },
75
+ {
76
+ "type": "string"
77
+ }
78
+ ]
79
+ },
80
+ "target": {
81
+ "description": "Browser compatibility target for the final bundle. For more info: https://vitejs.dev/config/build-options.html#build-target",
82
+ "type": "string"
83
+ },
84
+ "minify": {
85
+ "description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
86
+ "oneOf": [
87
+ {
88
+ "type": "boolean"
89
+ },
90
+ {
91
+ "type": "string"
92
+ }
93
+ ]
94
+ },
95
+ "manifest": {
96
+ "description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
97
+ "oneOf": [
98
+ {
99
+ "type": "boolean"
100
+ },
101
+ {
102
+ "type": "string"
103
+ }
104
+ ]
105
+ },
106
+ "ssrManifest": {
107
+ "description": "When set to true, the build will also generate an SSR manifest for determining style links and asset preload directives in production. When the value is a string, it will be used as the manifest file name.",
108
+ "oneOf": [
109
+ {
110
+ "type": "boolean"
111
+ },
112
+ {
113
+ "type": "string"
114
+ }
115
+ ]
116
+ },
117
+ "ssr": {
118
+ "description": "Produce SSR-oriented build. The value can be a string to directly specify the SSR entry, or true, which requires specifying the SSR entry via rollupOptions.input.",
119
+ "oneOf": [
120
+ {
121
+ "type": "boolean"
122
+ },
123
+ {
124
+ "type": "string"
125
+ }
126
+ ]
127
+ },
128
+ "logLevel": {
129
+ "type": "string",
130
+ "description": "Adjust console output verbosity.",
131
+ "enum": ["info", "warn", "error", "silent"]
132
+ },
133
+ "mode": {
134
+ "type": "string",
135
+ "description": "Mode to run the build in."
136
+ },
137
+ "force": {
138
+ "description": "Force the optimizer to ignore the cache and re-bundle",
139
+ "type": "boolean"
140
+ },
141
+ "cssCodeSplit": {
142
+ "description": "Enable/disable CSS code splitting. When enabled, CSS imported in async chunks will be inlined into the async chunk itself and inserted when the chunk is loaded.",
143
+ "type": "boolean"
144
+ },
43
145
  "watch": {
44
146
  "description": "Enable re-building when files change.",
45
147
  "oneOf": [
@@ -14,39 +14,23 @@ _export(exports, {
14
14
  }
15
15
  });
16
16
  const _extends = require("@swc/helpers/_/_extends");
17
- const _devkit = require("@nx/devkit");
18
17
  const _optionsutils = require("../../utils/options-utils");
19
18
  const _executorutils = require("../../utils/executor-utils");
20
- const _path = require("path");
21
- const _buildimpl = require("../build/build.impl");
22
19
  async function* viteDevServerExecutor(options, context) {
23
- process.env.VITE_CJS_IGNORE_WARNING = 'true';
24
20
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
25
- const { mergeConfig, createServer, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
21
+ const { mergeConfig, createServer } = await Function('return import("vite")')();
26
22
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
27
- const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
28
23
  (0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
29
24
  // Retrieve the option for the configured buildTarget.
30
25
  const buildTargetOptions = (0, _optionsutils.getNxTargetOptions)(options.buildTarget, context);
31
- const { configuration } = (0, _devkit.parseTargetString)(options.buildTarget, context);
32
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
33
- const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
34
- const { serverOptions, otherOptions } = await getServerExtraArgs(options, configuration, buildOptions, otherOptionsFromBuild);
35
- var _otherOptions_mode, _ref;
36
- const resolved = await loadConfigFromFile({
37
- mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : buildTargetOptions == null ? void 0 : buildTargetOptions['mode']) != null ? _ref : 'development',
38
- command: 'serve'
39
- }, viteConfigPath);
40
- var _resolved_config_root;
41
- // vite InlineConfig
42
- const serverConfig = mergeConfig({
43
- // This should not be needed as it's going to be set in vite.config.ts
44
- // but leaving it here in case someone did not migrate correctly
45
- root: (_resolved_config_root = resolved.config.root) != null ? _resolved_config_root : root,
46
- configFile: viteConfigPath
47
- }, _extends._({
48
- server: _extends._({}, await (0, _optionsutils.getViteServerOptions)(options, context), serverOptions)
49
- }, otherOptions));
26
+ // Merge the options from the build and dev-serve targets.
27
+ // The latter takes precedence.
28
+ const mergedOptions = _extends._({}, buildTargetOptions, options);
29
+ // Add the server specific configuration.
30
+ const serverConfig = mergeConfig((0, _optionsutils.getViteSharedConfig)(mergedOptions, options.clearScreen, context), {
31
+ build: (0, _optionsutils.getViteBuildOptions)(mergedOptions, context),
32
+ server: await (0, _optionsutils.getViteServerOptions)(mergedOptions, context)
33
+ });
50
34
  try {
51
35
  const server = await createServer(serverConfig);
52
36
  await runViteDevServer(server);
@@ -72,7 +56,6 @@ async function* viteDevServerExecutor(options, context) {
72
56
  process.once('exit', ()=>resolve());
73
57
  });
74
58
  }
75
- // vite ViteDevServer
76
59
  async function runViteDevServer(server) {
77
60
  await server.listen();
78
61
  server.printUrls();
@@ -84,53 +67,5 @@ async function runViteDevServer(server) {
84
67
  process.once('exit', processOnExit);
85
68
  }
86
69
  const _default = viteDevServerExecutor;
87
- async function getServerExtraArgs(options, configuration, buildOptionsFromBuildTarget, otherOptionsFromBuildTarget) {
88
- // support passing extra args to vite cli
89
- const schema = await Promise.resolve().then(()=>require("./schema.json"));
90
- const extraArgs = {};
91
- for (const key of Object.keys(options)){
92
- if (!schema.properties[key]) {
93
- extraArgs[key] = options[key];
94
- }
95
- }
96
- let serverOptions = {};
97
- const serverSchemaKeys = [
98
- 'hmr',
99
- 'warmup',
100
- 'watch',
101
- 'middlewareMode',
102
- 'fs',
103
- 'origin',
104
- 'preTransformRequests',
105
- 'sourcemapIgnoreList',
106
- 'port',
107
- 'strictPort',
108
- 'host',
109
- 'https',
110
- 'open',
111
- 'proxy',
112
- 'cors',
113
- 'headers'
114
- ];
115
- let otherOptions = {};
116
- for (const key of Object.keys(extraArgs)){
117
- if (serverSchemaKeys.includes(key)) {
118
- serverOptions[key] = extraArgs[key];
119
- } else {
120
- otherOptions[key] = extraArgs[key];
121
- }
122
- }
123
- if (configuration) {
124
- var _buildOptionsFromBuildTarget_watch;
125
- serverOptions = _extends._({}, serverOptions, {
126
- watch: (_buildOptionsFromBuildTarget_watch = buildOptionsFromBuildTarget == null ? void 0 : buildOptionsFromBuildTarget.watch) != null ? _buildOptionsFromBuildTarget_watch : serverOptions == null ? void 0 : serverOptions.watch
127
- });
128
- otherOptions = _extends._({}, otherOptions, otherOptionsFromBuildTarget != null ? otherOptionsFromBuildTarget : {});
129
- }
130
- return {
131
- serverOptions,
132
- otherOptions
133
- };
134
- }
135
70
 
136
71
  //# sourceMappingURL=dev-server.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n parseTargetString,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getViteServerOptions,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteDevServerExecutorOptions } from './schema';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n} from '../../utils/executor-utils';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\n\nexport async function* viteDevServerExecutor(\n options: ViteDevServerExecutorOptions,\n context: ExecutorContext\n): AsyncGenerator<{ success: boolean; baseUrl: string }> {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, createServer, loadConfigFromFile } =\n await loadViteDynamicImport();\n\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n createBuildableTsConfig(projectRoot, options, context);\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n const { serverOptions, otherOptions } = await getServerExtraArgs(\n options,\n configuration,\n buildOptions,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development',\n command: 'serve',\n },\n viteConfigPath\n );\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n server: {\n ...(await getViteServerOptions(options, context)),\n ...serverOptions,\n },\n ...otherOptions,\n }\n );\n\n try {\n const server = await createServer(serverConfig);\n await runViteDevServer(server);\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n// vite ViteDevServer\nasync function runViteDevServer(server: Record<string, any>): Promise<void> {\n await server.listen();\n\n server.printUrls();\n\n const processOnExit = async () => {\n await server.close();\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n}\n\nexport default viteDevServerExecutor;\n\nasync function getServerExtraArgs(\n options: ViteDevServerExecutorOptions,\n configuration: string | undefined,\n buildOptionsFromBuildTarget: Record<string, unknown> | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite ServerOptions\n serverOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n let serverOptions: Record<string, unknown> = {};\n const serverSchemaKeys = [\n 'hmr',\n 'warmup',\n 'watch',\n 'middlewareMode',\n 'fs',\n 'origin',\n 'preTransformRequests',\n 'sourcemapIgnoreList',\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (serverSchemaKeys.includes(key)) {\n serverOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n serverOptions = {\n ...serverOptions,\n watch: buildOptionsFromBuildTarget?.watch ?? serverOptions?.watch,\n };\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n serverOptions,\n otherOptions,\n };\n}\n"],"names":["viteDevServerExecutor","options","context","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","createServer","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","cwd","relative","joinPathFragments","createBuildableTsConfig","buildTargetOptions","getNxTargetOptions","buildTarget","configuration","parseTargetString","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","viteConfigPath","normalizeViteConfigFilePath","configFile","serverOptions","getServerExtraArgs","resolved","mode","command","serverConfig","config","server","getViteServerOptions","runViteDevServer","resolvedUrls","local","network","success","baseUrl","e","console","error","Promise","resolve","once","listen","printUrls","processOnExit","close","buildOptionsFromBuildTarget","otherOptionsFromBuildTarget","schema","extraAr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nB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC7D,SAAU;QACtC,IAAI,CAACyD,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAG3D,OAAO,CAAC2D,IAAI;QAC/B;IACF;IAEA,IAAI7B,gBAAyC,CAAC;IAC9C,MAAMiC,mBAAmB;QACvB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,IAAIvC,eAAe,CAAC;IACpB,KAAK,MAAMmC,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,iBAAiBC,QAAQ,CAACL,MAAM;YAClC7B,aAAa,CAAC6B,IAAI,GAAGD,SAAS,CAACC,IAAI;QACrC,OAAO;YACLnC,YAAY,CAACmC,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAItC,eAAe;YAGRkC;QAFTzB,gBAAgB,eACXA;YACHmC,OAAOV,CAAAA,qCAAAA,+CAAAA,4BAA6BU,KAAK,YAAlCV,qCAAsCzB,iCAAAA,cAAemC,KAAK;;QAEnEzC,eAAe,eACVA,cACCgC,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACL1B;QACAN;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/dev-server.impl.ts"],"sourcesContent":["import { ExecutorContext } from '@nx/devkit';\nimport type { InlineConfig, ViteDevServer } from 'vite';\n\nimport {\n getNxTargetOptions,\n getViteBuildOptions,\n getViteServerOptions,\n getViteSharedConfig,\n} from '../../utils/options-utils';\n\nimport { ViteDevServerExecutorOptions } from './schema';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { createBuildableTsConfig } from '../../utils/executor-utils';\n\nexport async function* viteDevServerExecutor(\n options: ViteDevServerExecutorOptions,\n context: ExecutorContext\n): AsyncGenerator<{ success: boolean; baseUrl: string }> {\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, createServer } = await (Function(\n 'return import(\"vite\")'\n )() as Promise<typeof import('vite')>);\n\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n\n createBuildableTsConfig(projectRoot, options, context);\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n // Merge the options from the build and dev-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...buildTargetOptions,\n ...options,\n };\n\n // Add the server specific configuration.\n const serverConfig: InlineConfig = mergeConfig(\n getViteSharedConfig(mergedOptions, options.clearScreen, context),\n {\n build: getViteBuildOptions(mergedOptions, context),\n server: await getViteServerOptions(mergedOptions, context),\n }\n );\n\n try {\n const server = await createServer(serverConfig);\n await runViteDevServer(server);\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nasync function runViteDevServer(server: ViteDevServer): Promise<void> {\n await server.listen();\n server.printUrls();\n\n const processOnExit = async () => {\n await server.close();\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n}\n\nexport default viteDevServerExecutor;\n"],"names":["viteDevServerExecutor","options","context","mergeConfig","createServer","Function","projectRoot","projectsConfigurations","projects","projectName","root","createBuildableTsConfig","buildTargetOptions","getNxTargetOptions","buildTarget","mergedOptions","serverConfig","getViteSharedConfig","clearScreen","build","getViteBuildOptions","server","getViteServerOptions","runViteDevServer","resolvedUrls","local","network","success","baseUrl","e","console","error","Promise","resolve","process","once","listen","printUrls","processOnExit","close"],"mappings":";;;;;;;;IAcuBA,qBAAqB;eAArBA;;I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ACnBf,OAAOgB,SAAS;IAEhB,MAAMC,gBAAgB;QACpB,MAAMjB,OAAOkB,KAAK;IACpB;IAEAL,QAAQC,IAAI,CAAC,UAAUG;IACvBJ,QAAQC,IAAI,CAAC,WAAWG;IACxBJ,QAAQC,IAAI,CAAC,QAAQG;AACvB;MAEA,WAAetC"}
@@ -2,4 +2,14 @@ export interface ViteDevServerExecutorOptions {
2
2
  buildTarget: string;
3
3
  buildLibsFromSource?: boolean;
4
4
  proxyConfig?: string;
5
+ port?: number;
6
+ host?: string | boolean;
7
+ https?: boolean | Json;
8
+ hmr?: boolean;
9
+ open?: string | boolean;
10
+ cors?: boolean;
11
+ logLevel?: 'info' | 'warn' | 'error' | 'silent';
12
+ mode?: string;
13
+ clearScreen?: boolean;
14
+ force?: boolean;
5
15
  }
@@ -30,6 +30,69 @@
30
30
  "type": "string",
31
31
  "description": "Path to the proxy configuration file.",
32
32
  "x-completion-type": "file"
33
+ },
34
+ "port": {
35
+ "type": "number",
36
+ "description": "Port to listen on.",
37
+ "x-priority": "important"
38
+ },
39
+ "host": {
40
+ "description": "Specify which IP addresses the server should listen on.",
41
+ "oneOf": [
42
+ {
43
+ "type": "boolean"
44
+ },
45
+ {
46
+ "type": "string"
47
+ }
48
+ ]
49
+ },
50
+ "https": {
51
+ "oneOf": [
52
+ {
53
+ "type": "boolean"
54
+ },
55
+ {
56
+ "type": "object"
57
+ }
58
+ ],
59
+ "description": "Serve using HTTPS. https://vitejs.dev/config/server-options.html#server-https"
60
+ },
61
+ "hmr": {
62
+ "description": "Enable hot module replacement. For more options, use the 'hmr' option in the Vite configuration file.",
63
+ "type": "boolean"
64
+ },
65
+ "open": {
66
+ "description": "Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname.",
67
+ "oneOf": [
68
+ {
69
+ "type": "boolean"
70
+ },
71
+ {
72
+ "type": "string"
73
+ }
74
+ ]
75
+ },
76
+ "cors": {
77
+ "description": "Configure CORS for the dev server.",
78
+ "type": "boolean"
79
+ },
80
+ "logLevel": {
81
+ "type": "string",
82
+ "description": "Adjust console output verbosity.",
83
+ "enum": ["info", "warn", "error", "silent"]
84
+ },
85
+ "mode": {
86
+ "type": "string",
87
+ "description": "Mode to run the server in."
88
+ },
89
+ "clearScreen": {
90
+ "description": "Set to false to prevent Vite from clearing the terminal screen when logging certain messages.",
91
+ "type": "boolean"
92
+ },
93
+ "force": {
94
+ "description": "Force the optimizer to ignore the cache and re-bundle",
95
+ "type": "boolean"
33
96
  }
34
97
  },
35
98
  "definitions": {},
@@ -2,6 +2,6 @@ import { ExecutorContext } from '@nx/devkit';
2
2
  import { VitePreviewServerExecutorOptions } from './schema';
3
3
  export declare function vitePreviewServerExecutor(options: VitePreviewServerExecutorOptions, context: ExecutorContext): AsyncGenerator<{
4
4
  success: boolean;
5
- baseUrl: any;
5
+ baseUrl: string;
6
6
  }, void, unknown>;
7
7
  export default vitePreviewServerExecutor;
@@ -16,15 +16,10 @@ _export(exports, {
16
16
  const _extends = require("@swc/helpers/_/_extends");
17
17
  const _devkit = require("@nx/devkit");
18
18
  const _optionsutils = require("../../utils/options-utils");
19
- const _path = require("path");
20
- const _buildimpl = require("../build/build.impl");
21
- const _executorutils = require("../../utils/executor-utils");
22
19
  async function* vitePreviewServerExecutor(options, context) {
23
- var _context_projectsConfigurations_projects_target_project, _resolved_config_build, _resolved_config;
24
- process.env.VITE_CJS_IGNORE_WARNING = 'true';
20
+ var _context_projectsConfigurations_projects_target_project;
25
21
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
26
- const { mergeConfig, preview, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
27
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
22
+ const { mergeConfig, preview } = await Function('return import("vite")')();
28
23
  const target = (0, _devkit.parseTargetString)(options.buildTarget, context);
29
24
  const targetConfiguration = (_context_projectsConfigurations_projects_target_project = context.projectsConfigurations.projects[target.project]) == null ? void 0 : _context_projectsConfigurations_projects_target_project.targets[target.target];
30
25
  if (!targetConfiguration) {
@@ -33,44 +28,26 @@ async function* vitePreviewServerExecutor(options, context) {
33
28
  const isCustomBuildTarget = targetConfiguration.executor !== '@nx/vite:build' && targetConfiguration.executor !== '@nrwl/vite:build';
34
29
  // Retrieve the option for the configured buildTarget.
35
30
  const buildTargetOptions = (0, _optionsutils.getNxTargetOptions)(options.buildTarget, context);
36
- const { configuration } = (0, _devkit.parseTargetString)(options.buildTarget, context);
37
- const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
38
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
39
- const { previewOptions, otherOptions } = await getExtraArgs(options, configuration, otherOptionsFromBuild);
40
- var _otherOptions_mode, _ref;
41
- const resolved = await loadConfigFromFile({
42
- mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : otherOptionsFromBuild == null ? void 0 : otherOptionsFromBuild.mode) != null ? _ref : 'production',
43
- command: 'build'
44
- }, viteConfigPath);
45
- var _options_staticFilePath, _ref1;
46
- const outDir = (_ref1 = (_options_staticFilePath = options.staticFilePath) != null ? _options_staticFilePath : (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath)) != null ? _ref1 : resolved == null ? void 0 : (_resolved_config = resolved.config) == null ? void 0 : (_resolved_config_build = _resolved_config.build) == null ? void 0 : _resolved_config_build.outDir;
47
- if (!outDir) {
48
- throw new Error(`Could not infer the "outputPath" or "outDir". It should be set in your vite.config.ts, or as a property of the "${options.buildTarget}" buildTarget or provided explicitly as a "staticFilePath" option.`);
31
+ var _options_staticFilePath;
32
+ const outputPath = (_options_staticFilePath = options.staticFilePath) != null ? _options_staticFilePath : buildTargetOptions.outputPath;
33
+ if (!outputPath) {
34
+ throw new Error(`Could not infer the "outputPath". It should either be a property of the "${options.buildTarget}" buildTarget or provided explicitly as a "staticFilePath" option.`);
49
35
  }
50
- const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
51
36
  // Merge the options from the build and preview-serve targets.
52
37
  // The latter takes precedence.
53
38
  const mergedOptions = _extends._({}, {
54
39
  watch: {}
55
- }, {
56
- build: _extends._({
57
- outDir
58
- }, isCustomBuildTarget ? {} : buildOptions)
59
- }, isCustomBuildTarget ? {} : otherOptionsFromBuild, otherOptions, {
60
- preview: _extends._({}, (0, _optionsutils.getProxyConfig)(context, otherOptions.proxyConfig), previewOptions)
40
+ }, isCustomBuildTarget ? {} : buildTargetOptions, options, {
41
+ outputPath
42
+ });
43
+ // Retrieve the server configuration.
44
+ const serverConfig = mergeConfig((0, _optionsutils.getViteSharedConfig)(mergedOptions, options.clearScreen, context), {
45
+ build: (0, _optionsutils.getViteBuildOptions)(mergedOptions, context),
46
+ preview: (0, _optionsutils.getVitePreviewOptions)(mergedOptions, context)
61
47
  });
62
- var _resolved_config_root;
63
- // vite InlineConfig
64
- const serverConfig = mergeConfig({
65
- // This should not be needed as it's going to be set in vite.config.ts
66
- // but leaving it here in case someone did not migrate correctly
67
- root: (_resolved_config_root = resolved.config.root) != null ? _resolved_config_root : root,
68
- configFile: viteConfigPath
69
- }, _extends._({}, mergedOptions));
70
48
  if (serverConfig.mode === 'production') {
71
49
  console.warn('WARNING: preview is not meant to be run in production!');
72
50
  }
73
- // vite PreviewServer
74
51
  let server;
75
52
  const processOnExit = async ()=>{
76
53
  await closeServer(server);
@@ -124,53 +101,12 @@ function closeServer(server) {
124
101
  resolve();
125
102
  } else {
126
103
  const { httpServer } = server;
127
- if (httpServer['closeAllConnections']) {
128
- // https://github.com/vitejs/vite/pull/14834
129
- // closeAllConnections was added in Node v18.2.0
130
- // typically is "as http.Server" but no reason
131
- // to import http just for this
132
- httpServer.closeAllConnections();
133
- }
104
+ // closeAllConnections was added in Node v18.2.0
105
+ httpServer.closeAllConnections && httpServer.closeAllConnections();
134
106
  httpServer.close(()=>resolve());
135
107
  }
136
108
  });
137
109
  }
138
110
  const _default = vitePreviewServerExecutor;
139
- async function getExtraArgs(options, configuration, otherOptionsFromBuildTarget) {
140
- // support passing extra args to vite cli
141
- const schema = await Promise.resolve().then(()=>require("./schema.json"));
142
- const extraArgs = {};
143
- for (const key of Object.keys(options)){
144
- if (!schema.properties[key]) {
145
- extraArgs[key] = options[key];
146
- }
147
- }
148
- const previewOptions = {};
149
- const previewSchemaKeys = [
150
- 'port',
151
- 'strictPort',
152
- 'host',
153
- 'https',
154
- 'open',
155
- 'proxy',
156
- 'cors',
157
- 'headers'
158
- ];
159
- let otherOptions = {};
160
- for (const key of Object.keys(extraArgs)){
161
- if (previewSchemaKeys.includes(key)) {
162
- previewOptions[key] = extraArgs[key];
163
- } else {
164
- otherOptions[key] = extraArgs[key];
165
- }
166
- }
167
- if (configuration) {
168
- otherOptions = _extends._({}, otherOptions, otherOptionsFromBuildTarget != null ? otherOptionsFromBuildTarget : {});
169
- }
170
- return {
171
- previewOptions,
172
- otherOptions
173
- };
174
- }
175
111
 
176
112
  //# sourceMappingURL=preview-server.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n offsetFromRoot,\n parseTargetString,\n runExecutor,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getProxyConfig,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\nimport { loadViteDynamicImport } from '../../utils/executor-utils';\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const { previewOptions, otherOptions } = await getExtraArgs(\n options,\n configuration,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n options.staticFilePath ??\n joinPathFragments(\n offsetFromRoot(projectRoot),\n buildTargetOptions.outputPath\n ) ??\n resolved?.config?.build?.outDir;\n\n if (!outDir) {\n throw new Error(\n `Could not infer the \"outputPath\" or \"outDir\". It should be set in your vite.config.ts, or as a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n build: {\n outDir,\n ...(isCustomBuildTarget ? {} : buildOptions),\n },\n ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),\n ...otherOptions,\n preview: {\n ...getProxyConfig(context, otherOptions.proxyConfig),\n ...previewOptions,\n },\n };\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n ...mergedOptions,\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n // vite PreviewServer\n let server: Record<string, any> | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: Record<string, any>): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n if (httpServer['closeAllConnections']) {\n // https://github.com/vitejs/vite/pull/14834\n // closeAllConnections was added in Node v18.2.0\n // typically is \"as http.Server\" but no reason\n // to import http just for this\n (httpServer as any).closeAllConnections();\n }\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n\nasync function getExtraArgs(\n options: VitePreviewServerExecutorOptions,\n configuration: string | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite PreviewOptions\n previewOptions: Record<string, any>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const previewOptions = {};\n const previewSchemaKeys = [\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (previewSchemaKeys.includes(key)) {\n previewOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n previewOptions,\n otherOptions,\n };\n}\n"],"names":["vitePreviewServerExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","preview","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","target","parseTargetString","buildTarget","targetConfiguration","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","configuration","viteConfigPath","normalizeViteConfigFilePath","configFile","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","previewOptions","getExtraArgs","mode","command","outDir","staticFilePath","joinPathFragments","offsetFromRoot","outputPath","config","build","cwd","relative","mergedOptions","watch","getProxyConfig","proxyConfig","serverConfig","console","warn","server","processOnExit","closeServer","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","previewSchemaKeys","includes"],"mappings":";;;;;;;;IAkBuBA,yBAAyB;eAAzBA;;IAiLvB,OAAyC;eAAzC;;;;wBA7LO;8BAKA;sBAGkB;2BACS;+BACI;AAE/B,gBAAgBA,0BACrBC,OAAyC,EACzCC,OAAwB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;MAEA,WAAevE;AAEf,eAAeoC,aACbnC,OAAyC,EACzC0B,aAAiC,EACjCgD,2BAAgE;IAMhE,yCAAyC;IACzC,MAAMC,SAAS,MAAM,2BAAA,QAAO;IAC5B,MAAMC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC/E,SAAU;QACtC,IAAI,CAAC2E,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAG7E,OAAO,CAAC6E,IAAI;QAC/B;IACF;IAEA,MAAM3C,iBAAiB,CAAC;IACxB,MAAM+C,oBAAoB;QACxB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,IAAIlD,eAAe,CAAC;IACpB,KAAK,MAAM8C,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,kBAAkBC,QAAQ,CAACL,MAAM;YACnC3C,cAAc,CAAC2C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACtC,OAAO;YACL9C,YAAY,CAAC8C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAInD,eAAe;QACjBK,eAAe,eACVA,cACC2C,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACLxC;QACAH;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import { ExecutorContext, parseTargetString, runExecutor } from '@nx/devkit';\nimport type { InlineConfig, PreviewServer } from 'vite';\nimport {\n getNxTargetOptions,\n getViteBuildOptions,\n getVitePreviewOptions,\n getViteSharedConfig,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\n\ninterface CustomBuildTargetOptions {\n outputPath: string;\n}\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview } = await (Function(\n 'return import(\"vite\")'\n )() as Promise<typeof import('vite')>);\n\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions:\n | ViteBuildExecutorOptions\n | CustomBuildTargetOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const outputPath = options.staticFilePath ?? buildTargetOptions.outputPath;\n\n if (!outputPath) {\n throw new Error(\n `Could not infer the \"outputPath\". It should either be a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n ...(isCustomBuildTarget ? {} : buildTargetOptions),\n ...options,\n outputPath,\n };\n\n // Retrieve the server configuration.\n const serverConfig: InlineConfig = mergeConfig(\n getViteSharedConfig(mergedOptions, options.clearScreen, context),\n {\n build: getViteBuildOptions(mergedOptions, context),\n preview: getVitePreviewOptions(mergedOptions, context),\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n let server: PreviewServer | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: PreviewServer): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n // closeAllConnections was added in Node v18.2.0\n httpServer.closeAllConnections && httpServer.closeAllConnections();\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n"],"names":["vitePreviewServerExecutor","options","context","mergeConfig","preview","Function","target","parseTargetString","buildTarget","targetConfiguration","projectsConfigurations","projects","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","outputPath","staticFilePath","mergedOptions","watch","serverConfig","getViteSharedConfig","clearScreen","build","getViteBuildOptions","getVitePreviewOptions","mode","console","warn","server","processOnExit","closeServer","process","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close"],"mappings":";;;;;;;;IAeuBA,yBAAyB;eAAzBA;;IA+HvB,OAAyC;eAAzC;;;;wBA9IgE;8BAOzD;AAQA,gBAAgBA,0BACrBC,OAAyC,EACzCC,OAAwB;QAStBA;IAPF,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAG,MAAOC,SACtC;IAGF,MAAMC,SAASC,IAAAA,yBAAiB,EAACN,QAAQO,WAAW,EAAEN;IACtD,MAAMO,uBACJP,0DAAAA,QAAQQ,sBAAsB,CAACC,QAAQ,CAACL,OAAOM,OAAO,CAAC,qBAAvDV,wDAAyDW,OAAO,CAC9DP,OAAOA,MAAM,CACd;IACH,IAAI,CAACG,qBAAqB;QACxB,MAAM,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AI,CAACR,QAAQ;oBACXA,SAAS,MAAM5B,QAAQmB;gBACzB;gBACAS,OAAOS,SAAS;gBAEhB,MAAMC,eAAe;uBAChBV,OAAOU,YAAY,CAACC,KAAK;uBACzBX,OAAOU,YAAY,CAACE,OAAO;iBAC/B;oBAIUF;gBAFX,MAAM;oBACJF,SAAS;oBACTK,SAASH,CAAAA,iBAAAA,YAAY,CAAC,EAAE,YAAfA,iBAAmB;gBAC9B;YACF,EAAE,OAAOI,GAAG;gBACVhB,QAAQiB,KAAK,CAACD;gBACd,MAAM;oBACJN,SAAS;oBACTK,SAAS;gBACX;YACF;QACF,OAAO;YACL,MAAM;gBACJL,SAAS;gBACTK,SAAS;YACX;QACF;IACF;IAEA,MAAM,IAAIG,QAAc,CAACC;QACvBd,QAAQC,IAAI,CAAC,UAAU,IAAMa;QAC7Bd,QAAQC,IAAI,CAAC,WAAW,IAAMa;QAC9Bd,QAAQC,IAAI,CAAC,QAAQ,IAAMa;IAC7B;AACF;AAEA,SAASf,YAAYF,MAAsB;IACzC,OAAO,IAAIgB,QAAQ,CAACC;QAClB,IAAI,CAACjB,QAAQ;YACXiB;QACF,OAAO;YACL,MAAM,EAAEC,UAAU,EAAE,GAAGlB;YACvB,gDAAgD;YAChDkB,WAAWC,mBAAmB,IAAID,WAAWC,mBAAmB;YAChED,WAAWE,KAAK,CAAC,IAAMH;QACzB;IACF;AACF;MAEA,WAAejD"}
@@ -1,5 +1,12 @@
1
1
  export interface VitePreviewServerExecutorOptions {
2
2
  buildTarget: string;
3
3
  proxyConfig?: string;
4
+ port?: number;
5
+ host?: string | boolean;
6
+ https?: boolean | Json;
7
+ open?: string | boolean;
8
+ logLevel?: 'info' | 'warn' | 'error' | 'silent';
9
+ mode?: string;
10
+ clearScreen?: boolean;
4
11
  staticFilePath?: string;
5
12
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "cli": "nx",
5
5
  "title": "Vite Preview Server",
@@ -25,6 +25,56 @@
25
25
  "description": "Path to the proxy configuration file.",
26
26
  "x-completion-type": "file"
27
27
  },
28
+ "port": {
29
+ "type": "number",
30
+ "description": "Port to listen on."
31
+ },
32
+ "host": {
33
+ "description": "Specify which IP addresses the server should listen on.",
34
+ "oneOf": [
35
+ {
36
+ "type": "boolean"
37
+ },
38
+ {
39
+ "type": "string"
40
+ }
41
+ ]
42
+ },
43
+ "https": {
44
+ "oneOf": [
45
+ {
46
+ "type": "boolean"
47
+ },
48
+ {
49
+ "type": "object"
50
+ }
51
+ ],
52
+ "description": "Serve using HTTPS. https://vitejs.dev/config/server-options.html#server-https"
53
+ },
54
+ "open": {
55
+ "description": "Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname.",
56
+ "oneOf": [
57
+ {
58
+ "type": "boolean"
59
+ },
60
+ {
61
+ "type": "string"
62
+ }
63
+ ]
64
+ },
65
+ "logLevel": {
66
+ "type": "string",
67
+ "description": "Adjust console output verbosity.",
68
+ "enum": ["info", "warn", "error", "silent"]
69
+ },
70
+ "mode": {
71
+ "type": "string",
72
+ "description": "Mode to run the server in."
73
+ },
74
+ "clearScreen": {
75
+ "description": "Set to false to prevent Vite from clearing the terminal screen when logging certain messages.",
76
+ "type": "boolean"
77
+ },
28
78
  "staticFilePath": {
29
79
  "type": "string",
30
80
  "description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath",