@nx/web 23.3.0-pr.37036.f6e3fb2 → 23.3.0-pr.37224.268062c

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](<>)
13
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
14
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
- [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
15
+ [![Hours saved](https://img.shields.io/endpoint?url=https%3A%2F%2Fstaging.nx.app%2Fnx-cloud%2Fbadge%2F62d013ea0852fe0a2df74438%2Fhours-saved.json)](https://nx.dev/nx-cloud)
16
16
 
17
17
  </div>
18
18
 
@@ -29,6 +29,7 @@ function createApplicationFiles(tree, options) {
29
29
  tmpl: '',
30
30
  offsetFromRoot: rootOffset,
31
31
  rootTsConfigPath,
32
+ devServerPort: options.port ?? 4200,
32
33
  webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
33
34
  ? {
34
35
  compiler: options.compiler,
@@ -96,6 +97,12 @@ async function setupBundler(tree, options) {
96
97
  addPlugin: options.addPlugin,
97
98
  });
98
99
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
100
+ // Only when asked: @nx/webpack:dev-server already defaults to 4200.
101
+ if (options.port != null && project.targets?.serve) {
102
+ project.targets.serve.options ??= {};
103
+ project.targets.serve.options.port = options.port;
104
+ (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
105
+ }
99
106
  if (project.targets?.build) {
100
107
  const prodConfig = project.targets.build.configurations.production;
101
108
  const buildOptions = project.targets.build.options;
@@ -261,6 +268,7 @@ async function applicationGeneratorInternal(host, schema) {
261
268
  inSourceTests: options.inSourceTests,
262
269
  skipFormat: true,
263
270
  addPlugin: options.addPlugin,
271
+ port: options.port,
264
272
  });
265
273
  tasks.push(viteTask);
266
274
  createOrEditViteConfig(host, {
@@ -268,6 +276,8 @@ async function applicationGeneratorInternal(host, schema) {
268
276
  includeLib: false,
269
277
  includeVitest: options.unitTestRunner === 'vitest',
270
278
  inSourceTests: options.inSourceTests,
279
+ port: options.port,
280
+ previewPort: options.port,
271
281
  useEsmExtension: true,
272
282
  }, false);
273
283
  }
@@ -313,26 +323,27 @@ async function applicationGeneratorInternal(host, schema) {
313
323
  await (0, static_serve_configuration_1.default)(host, {
314
324
  buildTarget: `${options.projectName}:build`,
315
325
  spa: true,
326
+ port: options.port,
316
327
  });
317
328
  }
318
329
  let e2eWebServerInfo = {
319
- e2eWebServerAddress: `http://localhost:4200`,
330
+ e2eWebServerAddress: `http://localhost:${options.port ?? 4200}`,
320
331
  e2eWebServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:serve`,
321
332
  e2eCiWebServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:serve-static`,
322
- e2eCiBaseUrl: `http://localhost:4200`,
333
+ e2eCiBaseUrl: `http://localhost:${options.port ?? 4200}`,
323
334
  e2eDevServerTarget: `${options.projectName}:serve`,
324
335
  };
325
336
  if (options.bundler === 'webpack') {
326
337
  const { getWebpackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
327
338
  e2eWebServerInfo = await getWebpackE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.js`), options.addPlugin,
328
- // This generator has no `port` option, so there is never an explicit request
329
- // to pass on. The helper defaults to 4200 itself, and leaving this undefined
330
- // is what lets targetDefaults still apply.
331
- undefined);
339
+ // Undefined unless --port was passed, so targetDefaults still apply.
340
+ options.port);
332
341
  }
333
342
  else if (options.bundler === 'vite') {
334
343
  const { getViteE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
335
- e2eWebServerInfo = await getViteE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.ts`), options.addPlugin, 4200);
344
+ e2eWebServerInfo = await getViteE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.ts`), options.addPlugin, options.port ?? 4200,
345
+ // An explicit port serves both dev and preview, as in @nx/react:app.
346
+ options.port);
336
347
  }
337
348
  if (options.e2eTestRunner === 'cypress') {
338
349
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
@@ -8,7 +8,7 @@ module.exports = {
8
8
  clean: true,
9
9
  },
10
10
  devServer: {
11
- port: 4200
11
+ port: <%= devServerPort %>
12
12
  },
13
13
  plugins: [
14
14
  new NxAppWebpackPlugin({
@@ -22,4 +22,5 @@ export interface Schema {
22
22
  strict?: boolean;
23
23
  addPlugin?: boolean;
24
24
  useProjectJson?: boolean;
25
+ port?: number;
25
26
  }
@@ -114,6 +114,10 @@
114
114
  "useProjectJson": {
115
115
  "type": "boolean",
116
116
  "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
117
+ },
118
+ "port": {
119
+ "type": "number",
120
+ "description": "The port to use for the development server. Defaults to 4200."
117
121
  }
118
122
  },
119
123
  "required": ["directory"],
@@ -23,6 +23,10 @@
23
23
  "type": "boolean",
24
24
  "description": "Whether to set the 'spa' flag on the generated target.",
25
25
  "default": true
26
+ },
27
+ "port": {
28
+ "type": "number",
29
+ "description": "The port to serve on. Defaults to 4200."
26
30
  }
27
31
  },
28
32
  "required": ["buildTarget"]
@@ -4,6 +4,7 @@ interface WebStaticServeSchema {
4
4
  outputPath?: string;
5
5
  targetName?: string;
6
6
  spa?: boolean;
7
+ port?: number;
7
8
  }
8
9
  export declare function webStaticServeGenerator(tree: Tree, options: WebStaticServeSchema): Promise<void>;
9
10
  export default webStaticServeGenerator;
@@ -75,6 +75,8 @@ function addStaticConfig(tree, opts) {
75
75
  buildTarget: opts.buildTarget,
76
76
  staticFilePath: opts.outputPath,
77
77
  spa: opts.spa,
78
+ // Only when asked: @nx/web:file-server already defaults to 4200.
79
+ ...(opts.port != null ? { port: opts.port } : {}),
78
80
  },
79
81
  };
80
82
  projectConfig.targets[opts.targetName] = staticServeOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/web",
3
- "version": "23.3.0-pr.37036.f6e3fb2",
3
+ "version": "23.3.0-pr.37224.268062c",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -79,20 +79,20 @@
79
79
  "http-server": "^14.1.0",
80
80
  "picocolors": "^1.1.0",
81
81
  "tslib": "^2.3.0",
82
- "@nx/devkit": "23.3.0-pr.37036.f6e3fb2",
83
- "@nx/js": "23.3.0-pr.37036.f6e3fb2"
82
+ "@nx/devkit": "23.3.0-pr.37224.268062c",
83
+ "@nx/js": "23.3.0-pr.37224.268062c"
84
84
  },
85
85
  "devDependencies": {
86
- "nx": "23.3.0-pr.37036.f6e3fb2",
87
- "@nx/vitest": "23.3.0-pr.37036.f6e3fb2"
86
+ "nx": "23.3.0-pr.37224.268062c",
87
+ "@nx/vitest": "23.3.0-pr.37224.268062c"
88
88
  },
89
89
  "peerDependencies": {
90
- "@nx/cypress": "23.3.0-pr.37036.f6e3fb2",
91
- "@nx/eslint": "23.3.0-pr.37036.f6e3fb2",
92
- "@nx/jest": "23.3.0-pr.37036.f6e3fb2",
93
- "@nx/playwright": "23.3.0-pr.37036.f6e3fb2",
94
- "@nx/vite": "23.3.0-pr.37036.f6e3fb2",
95
- "@nx/webpack": "23.3.0-pr.37036.f6e3fb2"
90
+ "@nx/cypress": "23.3.0-pr.37224.268062c",
91
+ "@nx/eslint": "23.3.0-pr.37224.268062c",
92
+ "@nx/jest": "23.3.0-pr.37224.268062c",
93
+ "@nx/playwright": "23.3.0-pr.37224.268062c",
94
+ "@nx/vite": "23.3.0-pr.37224.268062c",
95
+ "@nx/webpack": "23.3.0-pr.37224.268062c"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@nx/cypress": {