@nx/webpack 18.1.0-beta.0 → 18.1.0-beta.10

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.1.0-beta.0",
3
+ "version": "18.1.0-beta.10",
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.1.0-beta.0",
67
- "@nx/js": "18.1.0-beta.0",
68
- "@nrwl/webpack": "18.1.0-beta.0"
66
+ "@nx/devkit": "18.1.0-beta.10",
67
+ "@nx/js": "18.1.0-beta.10",
68
+ "@nrwl/webpack": "18.1.0-beta.10"
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public"
@@ -21,7 +21,7 @@ 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);
24
+ normalizedOptions.assets = (0, normalize_options_1.normalizeAssets)(options.assets, root, sourceRoot, projectRoot);
25
25
  }
26
26
  return normalizedOptions;
27
27
  }
@@ -12,7 +12,10 @@ function configurationGenerator(tree, options) {
12
12
  exports.configurationGenerator = configurationGenerator;
13
13
  async function configurationGeneratorInternal(tree, options) {
14
14
  const tasks = [];
15
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
15
+ const nxJson = (0, devkit_1.readNxJson)(tree);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ options.addPlugin ??= addPluginDefault;
16
19
  const initTask = await (0, init_1.webpackInitGenerator)(tree, {
17
20
  ...options,
18
21
  skipFormat: true,
@@ -10,7 +10,10 @@ function webpackInitGenerator(tree, schema) {
10
10
  }
11
11
  exports.webpackInitGenerator = webpackInitGenerator;
12
12
  async function webpackInitGeneratorInternal(tree, schema) {
13
- schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
13
+ const nxJson = (0, devkit_1.readNxJson)(tree);
14
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
15
+ nxJson.useInferencePlugins !== false;
16
+ schema.addPlugin ??= addPluginDefault;
14
17
  if (schema.addPlugin) {
15
18
  addPlugin(tree);
16
19
  }
@@ -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): AssetGlobPattern[];
3
+ export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string): AssetGlobPattern[];
4
4
  export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
@@ -40,7 +40,7 @@ function normalizeOptions(options) {
40
40
  return {
41
41
  ...options,
42
42
  assets: options.assets
43
- ? normalizeAssets(options.assets, devkit_1.workspaceRoot, sourceRoot)
43
+ ? normalizeAssets(options.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
44
44
  : [],
45
45
  baseHref: options.baseHref ?? '/',
46
46
  commonChunk: options.commonChunk ?? true,
@@ -71,7 +71,7 @@ function normalizeOptions(options) {
71
71
  };
72
72
  }
73
73
  exports.normalizeOptions = normalizeOptions;
74
- function normalizeAssets(assets, root, sourceRoot) {
74
+ function normalizeAssets(assets, root, sourceRoot, projectRoot) {
75
75
  return assets.map((asset) => {
76
76
  if (typeof asset === 'string') {
77
77
  const assetPath = (0, devkit_1.normalizePath)(asset);
@@ -97,7 +97,11 @@ function normalizeAssets(assets, root, sourceRoot) {
97
97
  throw new Error('An asset cannot be written to a location outside of the output path.');
98
98
  }
99
99
  const assetPath = (0, devkit_1.normalizePath)(asset.input);
100
- const resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
100
+ let resolvedAssetPath = (0, path_1.resolve)(root, assetPath);
101
+ if (asset.input.startsWith('.')) {
102
+ const resolvedProjectRoot = (0, path_1.resolve)(root, projectRoot);
103
+ resolvedAssetPath = (0, path_1.resolve)(resolvedProjectRoot, assetPath);
104
+ }
101
105
  return {
102
106
  ...asset,
103
107
  input: resolvedAssetPath,
@@ -122,7 +122,7 @@ function PostcssCliResources(options) {
122
122
  const resourceCache = new Map();
123
123
  return Promise.all(urlDeclarations.map(async (decl) => {
124
124
  const value = decl.value;
125
- const urlRegex = /url(?:\(\s*['"]?)(.*?)(?:['"]?\s*\))/g;
125
+ const urlRegex = /url(?:\(\s*(['"]?))(.*?)(?:\1\s*\))/g;
126
126
  const segments = [];
127
127
  let match;
128
128
  let lastIndex = 0;
@@ -131,7 +131,7 @@ function PostcssCliResources(options) {
131
131
  const inputFile = decl.source && decl.source.input.file;
132
132
  const context = (inputFile && path.dirname(inputFile)) || loader.context;
133
133
  while ((match = urlRegex.exec(value))) {
134
- const originalUrl = match[1];
134
+ const originalUrl = match[2];
135
135
  let processedUrl;
136
136
  try {
137
137
  processedUrl = await process(originalUrl, context, resourceCache);
@@ -19,7 +19,7 @@ function withNx(pluginOptions = {}) {
19
19
  assets: options.assets
20
20
  ? options.assets
21
21
  : pluginOptions.assets
22
- ? (0, normalize_options_1.normalizeAssets)(pluginOptions.assets, options.root, options.sourceRoot)
22
+ ? (0, normalize_options_1.normalizeAssets)(pluginOptions.assets, options.root, options.sourceRoot, options.projectRoot)
23
23
  : [],
24
24
  root: context.root,
25
25
  projectName: context.projectName,