@nx/webpack 18.2.0-beta.1 → 18.2.0-beta.3
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/webpack",
|
|
3
|
-
"version": "18.2.0-beta.
|
|
3
|
+
"version": "18.2.0-beta.3",
|
|
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.
|
|
67
|
-
"@nx/js": "18.2.0-beta.
|
|
68
|
-
"@nrwl/webpack": "18.2.0-beta.
|
|
66
|
+
"@nx/devkit": "18.2.0-beta.3",
|
|
67
|
+
"@nx/js": "18.2.0-beta.3",
|
|
68
|
+
"@nrwl/webpack": "18.2.0-beta.3"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
@@ -21,7 +21,8 @@ function normalizeOptions(options, root, projectRoot, sourceRoot) {
|
|
|
21
21
|
: options.optimization,
|
|
22
22
|
};
|
|
23
23
|
if (options.assets) {
|
|
24
|
-
normalizedOptions.assets = (0, normalize_options_1.normalizeAssets)(options.assets, root, sourceRoot, projectRoot
|
|
24
|
+
normalizedOptions.assets = (0, normalize_options_1.normalizeAssets)(options.assets, root, sourceRoot, projectRoot, false // executor assets are relative to workspace root for consistency
|
|
25
|
+
);
|
|
25
26
|
}
|
|
26
27
|
return normalizedOptions;
|
|
27
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AssetGlobPattern, FileReplacement, NormalizedNxWebpackPluginOptions, NxWebpackPluginOptions } from '../nx-webpack-plugin-options';
|
|
2
2
|
export declare function normalizeOptions(options: NxWebpackPluginOptions): NormalizedNxWebpackPluginOptions;
|
|
3
|
-
export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string): AssetGlobPattern[];
|
|
3
|
+
export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string, resolveRelativePathsToProjectRoot?: boolean): AssetGlobPattern[];
|
|
4
4
|
export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
|
|
@@ -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
|
|
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,51 +28,55 @@ function normalizeOptions(options) {
|
|
|
27
28
|
if (configurationName) {
|
|
28
29
|
Object.assign(buildTargetOptions, targetConfig.configurations?.[configurationName]);
|
|
29
30
|
}
|
|
30
|
-
Object.assign(
|
|
31
|
+
Object.assign(combinedPluginAndMaybeExecutorOptions, options,
|
|
32
|
+
// executor options take precedence (especially for overriding with CLI args)
|
|
33
|
+
buildTargetOptions);
|
|
31
34
|
}
|
|
32
35
|
else {
|
|
33
|
-
Object.assign(
|
|
36
|
+
Object.assign(combinedPluginAndMaybeExecutorOptions, options,
|
|
37
|
+
// executor options take precedence (especially for overriding with CLI args)
|
|
38
|
+
originalTargetOptions);
|
|
34
39
|
}
|
|
35
|
-
normalizeRelativePaths(projectNode.data.root, options);
|
|
36
40
|
const sourceRoot = projectNode.data.sourceRoot ?? projectNode.data.root;
|
|
37
41
|
if (!options.main) {
|
|
38
42
|
throw new Error(`Missing "main" option for the entry file. Set this option in your Nx webpack plugin.`);
|
|
39
43
|
}
|
|
40
44
|
return {
|
|
41
|
-
...
|
|
42
|
-
assets:
|
|
43
|
-
? normalizeAssets(
|
|
45
|
+
...combinedPluginAndMaybeExecutorOptions,
|
|
46
|
+
assets: combinedPluginAndMaybeExecutorOptions.assets
|
|
47
|
+
? normalizeAssets(combinedPluginAndMaybeExecutorOptions.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
|
|
44
48
|
: [],
|
|
45
|
-
baseHref:
|
|
46
|
-
commonChunk:
|
|
47
|
-
compiler:
|
|
49
|
+
baseHref: combinedPluginAndMaybeExecutorOptions.baseHref ?? '/',
|
|
50
|
+
commonChunk: combinedPluginAndMaybeExecutorOptions.commonChunk ?? true,
|
|
51
|
+
compiler: combinedPluginAndMaybeExecutorOptions.compiler ?? 'babel',
|
|
48
52
|
configurationName,
|
|
49
|
-
deleteOutputPath:
|
|
50
|
-
extractCss:
|
|
51
|
-
fileReplacements: normalizeFileReplacements(devkit_1.workspaceRoot,
|
|
52
|
-
generateIndexHtml:
|
|
53
|
-
main:
|
|
54
|
-
namedChunks:
|
|
55
|
-
optimization:
|
|
56
|
-
outputFileName:
|
|
57
|
-
outputHashing:
|
|
58
|
-
|
|
53
|
+
deleteOutputPath: combinedPluginAndMaybeExecutorOptions.deleteOutputPath ?? true,
|
|
54
|
+
extractCss: combinedPluginAndMaybeExecutorOptions.extractCss ?? true,
|
|
55
|
+
fileReplacements: normalizeFileReplacements(devkit_1.workspaceRoot, combinedPluginAndMaybeExecutorOptions.fileReplacements),
|
|
56
|
+
generateIndexHtml: combinedPluginAndMaybeExecutorOptions.generateIndexHtml ?? true,
|
|
57
|
+
main: combinedPluginAndMaybeExecutorOptions.main,
|
|
58
|
+
namedChunks: combinedPluginAndMaybeExecutorOptions.namedChunks ?? !isProd,
|
|
59
|
+
optimization: combinedPluginAndMaybeExecutorOptions.optimization ?? isProd,
|
|
60
|
+
outputFileName: combinedPluginAndMaybeExecutorOptions.outputFileName ?? 'main.js',
|
|
61
|
+
outputHashing: combinedPluginAndMaybeExecutorOptions.outputHashing ??
|
|
62
|
+
(isProd ? 'all' : 'none'),
|
|
63
|
+
outputPath: combinedPluginAndMaybeExecutorOptions.outputPath,
|
|
59
64
|
projectGraph,
|
|
60
65
|
projectName,
|
|
61
66
|
projectRoot: projectNode.data.root,
|
|
62
67
|
root: devkit_1.workspaceRoot,
|
|
63
|
-
runtimeChunk:
|
|
64
|
-
scripts:
|
|
65
|
-
sourceMap:
|
|
68
|
+
runtimeChunk: combinedPluginAndMaybeExecutorOptions.runtimeChunk ?? true,
|
|
69
|
+
scripts: combinedPluginAndMaybeExecutorOptions.scripts ?? [],
|
|
70
|
+
sourceMap: combinedPluginAndMaybeExecutorOptions.sourceMap ?? !isProd,
|
|
66
71
|
sourceRoot,
|
|
67
|
-
styles:
|
|
68
|
-
target:
|
|
72
|
+
styles: combinedPluginAndMaybeExecutorOptions.styles ?? [],
|
|
73
|
+
target: combinedPluginAndMaybeExecutorOptions.target,
|
|
69
74
|
targetName,
|
|
70
|
-
vendorChunk:
|
|
75
|
+
vendorChunk: combinedPluginAndMaybeExecutorOptions.vendorChunk ?? !isProd,
|
|
71
76
|
};
|
|
72
77
|
}
|
|
73
78
|
exports.normalizeOptions = normalizeOptions;
|
|
74
|
-
function normalizeAssets(assets, root, sourceRoot, projectRoot) {
|
|
79
|
+
function normalizeAssets(assets, root, sourceRoot, projectRoot, resolveRelativePathsToProjectRoot = true) {
|
|
75
80
|
return assets.map((asset) => {
|
|
76
81
|
if (typeof asset === 'string') {
|
|
77
82
|
const assetPath = (0, devkit_1.normalizePath)(asset);
|
|
@@ -98,7 +103,7 @@ function normalizeAssets(assets, root, sourceRoot, projectRoot) {
|
|
|
98
103
|
}
|
|
99
104
|
const assetPath = (0, devkit_1.normalizePath)(asset.input);
|
|
100
105
|
let resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
|
|
101
|
-
if (asset.input.startsWith('.')) {
|
|
106
|
+
if (resolveRelativePathsToProjectRoot && asset.input.startsWith('.')) {
|
|
102
107
|
const resolvedProjectRoot = (0, path_1.resolve)(root, projectRoot);
|
|
103
108
|
resolvedAssetPath = (0, path_1.resolve)(resolvedProjectRoot, assetPath);
|
|
104
109
|
}
|
package/src/plugins/plugin.js
CHANGED