@nx/webpack 18.2.0-beta.0 → 18.2.0-beta.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "18.2.0-beta.0",
3
+ "version": "18.2.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -63,9 +63,9 @@
63
63
  "webpack-dev-server": "^4.9.3",
64
64
  "webpack-node-externals": "^3.0.0",
65
65
  "webpack-subresource-integrity": "^5.1.0",
66
- "@nx/devkit": "18.2.0-beta.0",
67
- "@nx/js": "18.2.0-beta.0",
68
- "@nrwl/webpack": "18.2.0-beta.0"
66
+ "@nx/devkit": "18.2.0-beta.2",
67
+ "@nx/js": "18.2.0-beta.2",
68
+ "@nrwl/webpack": "18.2.0-beta.2"
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public"
@@ -5,7 +5,7 @@ const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  function normalizeOptions(options) {
8
- const combinedOptions = {};
8
+ const combinedPluginAndMaybeExecutorOptions = {};
9
9
  const isProd = process.env.NODE_ENV === 'production';
10
10
  const projectName = process.env.NX_TASK_TARGET_PROJECT;
11
11
  const targetName = process.env.NX_TASK_TARGET_TARGET;
@@ -14,6 +14,7 @@ function normalizeOptions(options) {
14
14
  const projectGraph = (0, devkit_1.readCachedProjectGraph)();
15
15
  const projectNode = projectGraph.nodes[projectName];
16
16
  const targetConfig = projectNode.data.targets[targetName];
17
+ normalizeRelativePaths(projectNode.data.root, options);
17
18
  // Merge options from `@nx/webpack:webpack` into plugin options.
18
19
  // Options from `@nx/webpack:webpack` take precedence.
19
20
  const originalTargetOptions = targetConfig.options;
@@ -27,47 +28,49 @@ function normalizeOptions(options) {
27
28
  if (configurationName) {
28
29
  Object.assign(buildTargetOptions, targetConfig.configurations?.[configurationName]);
29
30
  }
30
- Object.assign(combinedOptions, buildTargetOptions);
31
+ Object.assign(combinedPluginAndMaybeExecutorOptions, buildTargetOptions, options // plugin options take precedence
32
+ );
31
33
  }
32
34
  else {
33
- Object.assign(combinedOptions, originalTargetOptions, options);
35
+ Object.assign(combinedPluginAndMaybeExecutorOptions, originalTargetOptions, options // plugin options take precedence
36
+ );
34
37
  }
35
- normalizeRelativePaths(projectNode.data.root, options);
36
38
  const sourceRoot = projectNode.data.sourceRoot ?? projectNode.data.root;
37
39
  if (!options.main) {
38
40
  throw new Error(`Missing "main" option for the entry file. Set this option in your Nx webpack plugin.`);
39
41
  }
40
42
  return {
41
- ...options,
42
- assets: options.assets
43
- ? normalizeAssets(options.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
43
+ ...combinedPluginAndMaybeExecutorOptions,
44
+ assets: combinedPluginAndMaybeExecutorOptions.assets
45
+ ? normalizeAssets(combinedPluginAndMaybeExecutorOptions.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
44
46
  : [],
45
- baseHref: options.baseHref ?? '/',
46
- commonChunk: options.commonChunk ?? true,
47
- compiler: options.compiler ?? 'babel',
47
+ baseHref: combinedPluginAndMaybeExecutorOptions.baseHref ?? '/',
48
+ commonChunk: combinedPluginAndMaybeExecutorOptions.commonChunk ?? true,
49
+ compiler: combinedPluginAndMaybeExecutorOptions.compiler ?? 'babel',
48
50
  configurationName,
49
- deleteOutputPath: options.deleteOutputPath ?? true,
50
- extractCss: options.extractCss ?? true,
51
- fileReplacements: normalizeFileReplacements(devkit_1.workspaceRoot, options.fileReplacements),
52
- generateIndexHtml: options.generateIndexHtml ?? true,
53
- main: options.main,
54
- namedChunks: options.namedChunks ?? !isProd,
55
- optimization: options.optimization ?? isProd,
56
- outputFileName: options.outputFileName ?? 'main.js',
57
- outputHashing: options.outputHashing ?? (isProd ? 'all' : 'none'),
58
- outputPath: options.outputPath,
51
+ deleteOutputPath: combinedPluginAndMaybeExecutorOptions.deleteOutputPath ?? true,
52
+ extractCss: combinedPluginAndMaybeExecutorOptions.extractCss ?? true,
53
+ fileReplacements: normalizeFileReplacements(devkit_1.workspaceRoot, combinedPluginAndMaybeExecutorOptions.fileReplacements),
54
+ generateIndexHtml: combinedPluginAndMaybeExecutorOptions.generateIndexHtml ?? true,
55
+ main: combinedPluginAndMaybeExecutorOptions.main,
56
+ namedChunks: combinedPluginAndMaybeExecutorOptions.namedChunks ?? !isProd,
57
+ optimization: combinedPluginAndMaybeExecutorOptions.optimization ?? isProd,
58
+ outputFileName: combinedPluginAndMaybeExecutorOptions.outputFileName ?? 'main.js',
59
+ outputHashing: combinedPluginAndMaybeExecutorOptions.outputHashing ??
60
+ (isProd ? 'all' : 'none'),
61
+ outputPath: combinedPluginAndMaybeExecutorOptions.outputPath,
59
62
  projectGraph,
60
63
  projectName,
61
64
  projectRoot: projectNode.data.root,
62
65
  root: devkit_1.workspaceRoot,
63
- runtimeChunk: options.runtimeChunk ?? true,
64
- scripts: options.scripts ?? [],
65
- sourceMap: options.sourceMap ?? !isProd,
66
+ runtimeChunk: combinedPluginAndMaybeExecutorOptions.runtimeChunk ?? true,
67
+ scripts: combinedPluginAndMaybeExecutorOptions.scripts ?? [],
68
+ sourceMap: combinedPluginAndMaybeExecutorOptions.sourceMap ?? !isProd,
66
69
  sourceRoot,
67
- styles: options.styles ?? [],
68
- target: options.target,
70
+ styles: combinedPluginAndMaybeExecutorOptions.styles ?? [],
71
+ target: combinedPluginAndMaybeExecutorOptions.target,
69
72
  targetName,
70
- vendorChunk: options.vendorChunk ?? !isProd,
73
+ vendorChunk: combinedPluginAndMaybeExecutorOptions.vendorChunk ?? !isProd,
71
74
  };
72
75
  }
73
76
  exports.normalizeOptions = normalizeOptions;
@@ -101,6 +101,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
101
101
  executor: '@nx/web:file-server',
102
102
  options: {
103
103
  buildTarget: options.buildTargetName,
104
+ spa: true,
104
105
  },
105
106
  };
106
107
  return targets;