@nx/webpack 17.0.4 → 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 (80) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +2 -2
  4. package/index.d.ts +1 -3
  5. package/index.js +2 -7
  6. package/migrations.json +0 -6
  7. package/package.json +5 -6
  8. package/src/executors/dev-server/dev-server.impl.js +17 -31
  9. package/src/executors/dev-server/lib/get-dev-server-config.d.ts +3 -2
  10. package/src/executors/dev-server/lib/get-dev-server-config.js +26 -18
  11. package/src/executors/dev-server/schema.d.ts +8 -8
  12. package/src/executors/webpack/lib/get-webpack-config.d.ts +5 -0
  13. package/src/executors/webpack/lib/get-webpack-config.js +16 -0
  14. package/src/executors/webpack/lib/normalize-options.d.ts +2 -1
  15. package/src/executors/webpack/lib/normalize-options.js +53 -9
  16. package/src/executors/webpack/schema.d.ts +7 -10
  17. package/src/executors/webpack/schema.json +50 -30
  18. package/src/executors/webpack/webpack.impl.js +16 -36
  19. package/src/generators/configuration/configuration.d.ts +2 -3
  20. package/src/generators/configuration/configuration.js +23 -95
  21. package/src/generators/configuration/schema.d.ts +0 -1
  22. package/src/generators/configuration/schema.json +1 -1
  23. package/src/generators/init/init.d.ts +0 -1
  24. package/src/generators/init/init.js +23 -48
  25. package/src/generators/init/schema.d.ts +2 -4
  26. package/src/generators/init/schema.json +13 -18
  27. package/src/plugins/generate-package-json-plugin.d.ts +4 -6
  28. package/src/plugins/generate-package-json-plugin.js +14 -11
  29. package/src/utils/config.d.ts +6 -11
  30. package/src/utils/config.js +13 -48
  31. package/src/utils/get-client-environment.js +1 -4
  32. package/src/utils/module-federation/dependencies.js +3 -15
  33. package/src/utils/module-federation/get-remotes-for-host.js +1 -1
  34. package/src/utils/module-federation/remotes.js +1 -1
  35. package/src/utils/module-federation/secondary-entry-points.js +1 -1
  36. package/src/utils/module-federation/typescript.js +9 -14
  37. package/src/utils/versions.d.ts +0 -1
  38. package/src/utils/versions.js +1 -2
  39. package/src/utils/webpack/custom-webpack.d.ts +2 -0
  40. package/src/utils/webpack/{resolve-user-defined-webpack-config.js → custom-webpack.js} +8 -14
  41. package/src/utils/webpack/deprecated-stylus-loader.js +2 -2
  42. package/src/utils/webpack/interpolate-env-variables-to-index.js +1 -4
  43. package/src/utils/webpack/plugins/postcss-cli-resources.js +2 -2
  44. package/src/utils/with-nx.d.ts +58 -4
  45. package/src/utils/with-nx.js +362 -22
  46. package/src/utils/with-web.d.ts +2 -2
  47. package/src/utils/with-web.js +488 -9
  48. package/plugin.d.ts +0 -1
  49. package/plugin.js +0 -5
  50. package/src/migrations/update-17-2-1/webpack-config-setup.d.ts +0 -2
  51. package/src/migrations/update-17-2-1/webpack-config-setup.js +0 -31
  52. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +0 -8
  53. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +0 -31
  54. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +0 -5
  55. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +0 -318
  56. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +0 -5
  57. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +0 -372
  58. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +0 -53
  59. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +0 -78
  60. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +0 -1
  61. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +0 -35
  62. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +0 -3
  63. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +0 -42
  64. package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +0 -4
  65. package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +0 -148
  66. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +0 -73
  67. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +0 -117
  68. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.d.ts +0 -216
  69. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.js +0 -2
  70. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.d.ts +0 -17
  71. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.js +0 -48
  72. package/src/plugins/plugin.d.ts +0 -9
  73. package/src/plugins/plugin.js +0 -132
  74. package/src/utils/ensure-dependencies.d.ts +0 -6
  75. package/src/utils/ensure-dependencies.js +0 -28
  76. package/src/utils/has-plugin.d.ts +0 -2
  77. package/src/utils/has-plugin.js +0 -11
  78. package/src/utils/webpack/read-webpack-options.d.ts +0 -10
  79. package/src/utils/webpack/read-webpack-options.js +0 -41
  80. package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts +0 -3
@@ -1,216 +0,0 @@
1
- import { ProjectGraph } from '@nx/devkit';
2
- import { AssetGlob } from '@nx/js/src/utils/assets/assets';
3
- export interface AssetGlobPattern {
4
- glob: string;
5
- input: string;
6
- output: string;
7
- ignore?: string[];
8
- }
9
- export interface ExtraEntryPointClass {
10
- bundleName?: string;
11
- inject?: boolean;
12
- input: string;
13
- lazy?: boolean;
14
- }
15
- export interface FileReplacement {
16
- replace: string;
17
- with: string;
18
- }
19
- export interface AdditionalEntryPoint {
20
- entryName: string;
21
- entryPath: string;
22
- }
23
- export interface TransformerPlugin {
24
- name: string;
25
- options: Record<string, unknown>;
26
- }
27
- export type TransformerEntry = string | TransformerPlugin;
28
- export interface OptimizationOptions {
29
- scripts: boolean;
30
- styles: boolean;
31
- }
32
- export interface NxWebpackPluginOptions {
33
- /**
34
- * The tsconfig file for the project. e.g. `tsconfig.json`
35
- */
36
- tsConfig?: string;
37
- /**
38
- * The entry point for the bundle. e.g. `src/main.ts`
39
- */
40
- main?: string;
41
- /**
42
- * Secondary entry points for the bundle.
43
- */
44
- additionalEntryPoints?: AdditionalEntryPoint[];
45
- /**
46
- * Assets to be copied over to the output path.
47
- */
48
- assets?: Array<AssetGlob | string>;
49
- /**
50
- * Babel configuration file if compiler is babel.
51
- */
52
- babelConfig?: string;
53
- /**
54
- * If true, Babel will look for a babel.config.json up the directory tree.
55
- */
56
- babelUpwardRootMode?: boolean;
57
- /**
58
- * Set <base href> for the resulting index.html.
59
- */
60
- baseHref?: string;
61
- commonChunk?: boolean;
62
- /**
63
- * The compiler to use. Default is `babel` and requires a `.babelrc` file.
64
- */
65
- compiler?: 'babel' | 'swc' | 'tsc';
66
- /**
67
- * Set `crossorigin` attribute on the `script` and `link` tags.
68
- */
69
- crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
70
- /**
71
- * Delete the output path before building.
72
- */
73
- deleteOutputPath?: boolean;
74
- /**
75
- * The deploy path for the application. e.g. `/my-app/`
76
- */
77
- deployUrl?: string;
78
- /**
79
- * Define external packages that will not be bundled.
80
- * Use `all` to exclude all 3rd party packages, and `none` to bundle all packages.
81
- * Use an array to exclude specific packages from the bundle.
82
- * Default is `none`.
83
- */
84
- externalDependencies?: 'all' | 'none' | string[];
85
- /**
86
- * Extract CSS as an external file. Default is `true`.
87
- */
88
- extractCss?: boolean;
89
- /**
90
- * Extract licenses from 3rd party modules and add them to the output.
91
- */
92
- extractLicenses?: boolean;
93
- /**
94
- * Replace files at build time. e.g. `[{ "replace": "src/a.dev.ts", "with": "src/a.prod.ts" }]`
95
- */
96
- fileReplacements?: FileReplacement[];
97
- /**
98
- * Generate an `index.html` file if `index.html` is passed. Default is `true`
99
- */
100
- generateIndexHtml?: boolean;
101
- /**
102
- * Generate a `package.json` file for the bundle. Useful for Node applications.
103
- */
104
- generatePackageJson?: boolean;
105
- /**
106
- * Path to the `index.html`.
107
- */
108
- index?: string;
109
- /**
110
- * Set the memory limit for the type-checking process. Default is `2048`.
111
- */
112
- memoryLimit?: number;
113
- /**
114
- * Use the source file name in output chunks. Useful for development or for Node.
115
- */
116
- namedChunks?: boolean;
117
- /**
118
- * Optimize the bundle using Terser.
119
- */
120
- optimization?: boolean | OptimizationOptions;
121
- /**
122
- * Specify the output filename for the bundle. Useful for Node applications that use `@nx/js:node` to serve.
123
- */
124
- outputFileName?: string;
125
- /**
126
- * Use file hashes in the output filenames. Recommended for production web applications.
127
- */
128
- outputHashing?: any;
129
- /**
130
- * Override `output.path` in webpack configuration. This setting is not recommended and exists for backwards compatibility.
131
- */
132
- outputPath?: string;
133
- /**
134
- * Override `watchOptions.poll` in webpack configuration. This setting is not recommended and exists for backwards compatibility.
135
- */
136
- poll?: number;
137
- /**
138
- * The polyfill file to use. Useful for supporting legacy browsers. e.g. `src/polyfills.ts`
139
- */
140
- polyfills?: string;
141
- /**
142
- * Manually set the PostCSS configuration file. By default, PostCSS will look for `postcss.config.js` in the directory.
143
- */
144
- postcssConfig?: string;
145
- /**
146
- * Display build progress in the terminal.
147
- */
148
- progress?: boolean;
149
- /**
150
- * Add an additional chunk for the Webpack runtime. Defaults to `true` when `target === 'web'`.
151
- */
152
- runtimeChunk?: boolean;
153
- /**
154
- * External scripts that will be included before the main application entry.
155
- */
156
- scripts?: Array<ExtraEntryPointClass | string>;
157
- /**
158
- * Skip type checking. Default is `false`.
159
- */
160
- skipTypeChecking?: boolean;
161
- /**
162
- * Generate source maps.
163
- */
164
- sourceMap?: boolean | 'hidden';
165
- /**
166
- * When `true`, `process.env.NODE_ENV` will be excluded from the bundle. Useful for building a web application to run in a Node environment.
167
- */
168
- ssr?: boolean;
169
- /**
170
- * Generate a `stats.json` file which can be analyzed using tools such as `webpack-bundle-analyzer`.
171
- */
172
- statsJson?: boolean;
173
- /**
174
- * Options for the style preprocessor. e.g. `{ "includePaths": [] }` for SASS.
175
- */
176
- stylePreprocessorOptions?: any;
177
- /**
178
- * External stylesheets that will be included with the application.
179
- */
180
- styles?: Array<ExtraEntryPointClass | string>;
181
- /**
182
- * Enables the use of subresource integrity validation.
183
- */
184
- subresourceIntegrity?: boolean;
185
- /**
186
- * Override the `target` option in webpack configuration. This setting is not recommended and exists for backwards compatibility.
187
- */
188
- target?: string | string[];
189
- /**
190
- * List of TypeScript Compiler Transformers Plugins.
191
- */
192
- transformers?: TransformerEntry[];
193
- /**
194
- * Generate a separate vendor chunk for 3rd party packages.
195
- */
196
- vendorChunk?: boolean;
197
- /**
198
- * Log additional information for debugging purposes.
199
- */
200
- verbose?: boolean;
201
- /**
202
- * Watch for file changes.
203
- */
204
- watch?: boolean;
205
- }
206
- export interface NormalizedNxWebpackPluginOptions extends NxWebpackPluginOptions {
207
- projectName: string;
208
- root: string;
209
- projectRoot: string;
210
- sourceRoot: string;
211
- configurationName: string;
212
- targetName: string;
213
- projectGraph: ProjectGraph;
214
- outputFileName: string;
215
- assets: AssetGlobPattern[];
216
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- import { Compiler } from 'webpack';
2
- import { NxWebpackPluginOptions } from './nx-webpack-plugin-options';
3
- /**
4
- * This plugin provides features to build Node and Web applications.
5
- * - TS support (including tsconfig paths)
6
- * - Different compiler options
7
- * - Assets handling
8
- * - Stylesheets handling
9
- * - index.html and package.json generation
10
- *
11
- * Web-only features, such as stylesheets and images, are only supported when `target` is 'web' or 'webworker'.
12
- */
13
- export declare class NxWebpackPlugin {
14
- private readonly options;
15
- constructor(options?: NxWebpackPluginOptions);
16
- apply(compiler: Compiler): void;
17
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NxWebpackPlugin = void 0;
4
- const normalize_options_1 = require("./lib/normalize-options");
5
- const fs_1 = require("../../utils/fs");
6
- const apply_base_config_1 = require("./lib/apply-base-config");
7
- const apply_web_config_1 = require("./lib/apply-web-config");
8
- /**
9
- * This plugin provides features to build Node and Web applications.
10
- * - TS support (including tsconfig paths)
11
- * - Different compiler options
12
- * - Assets handling
13
- * - Stylesheets handling
14
- * - index.html and package.json generation
15
- *
16
- * Web-only features, such as stylesheets and images, are only supported when `target` is 'web' or 'webworker'.
17
- */
18
- class NxWebpackPlugin {
19
- constructor(options = {}) {
20
- // If we're building inferred targets, skip normalizing build options.
21
- if (!global.NX_GRAPH_CREATION) {
22
- this.options = (0, normalize_options_1.normalizeOptions)(options);
23
- }
24
- }
25
- apply(compiler) {
26
- // Defaults to 'web' if not specified to match Webpack's default.
27
- const target = this.options.target ?? compiler.options.target ?? 'web';
28
- this.options.outputPath ??= compiler.options.output?.path;
29
- if (typeof target === 'string') {
30
- this.options.target = target;
31
- }
32
- (0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options, {
33
- useNormalizedEntry: true,
34
- });
35
- if (compiler.options.target) {
36
- this.options.target = compiler.options.target;
37
- }
38
- if (this.options.target === 'web' || this.options.target === 'webworker') {
39
- (0, apply_web_config_1.applyWebConfig)(this.options, compiler.options, {
40
- useNormalizedEntry: true,
41
- });
42
- }
43
- if (this.options.deleteOutputPath) {
44
- (0, fs_1.deleteOutputDir)(this.options.root, this.options.outputPath);
45
- }
46
- }
47
- }
48
- exports.NxWebpackPlugin = NxWebpackPlugin;
@@ -1,9 +0,0 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
- export interface WebpackPluginOptions {
3
- buildTargetName?: string;
4
- serveTargetName?: string;
5
- serveStaticTargetName?: string;
6
- previewTargetName?: string;
7
- }
8
- export declare const createDependencies: CreateDependencies;
9
- export declare const createNodes: CreateNodes<WebpackPluginOptions>;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
7
- const fs_1 = require("fs");
8
- const read_webpack_options_1 = require("../utils/webpack/read-webpack-options");
9
- const resolve_user_defined_webpack_config_1 = require("../utils/webpack/resolve-user-defined-webpack-config");
10
- const js_1 = require("@nx/js");
11
- const cache_directory_1 = require("nx/src/utils/cache-directory");
12
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
13
- const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'webpack.hash');
14
- const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
15
- const calculatedTargets = {};
16
- function readTargetsCache() {
17
- return (0, devkit_1.readJsonFile)(cachePath);
18
- }
19
- function writeTargetsToCache(targets) {
20
- (0, devkit_1.writeJsonFile)(cachePath, targets);
21
- }
22
- const createDependencies = () => {
23
- writeTargetsToCache(calculatedTargets);
24
- return [];
25
- };
26
- exports.createDependencies = createDependencies;
27
- exports.createNodes = [
28
- '**/webpack.config.{js,ts,mjs,cjs}',
29
- async (configFilePath, options, context) => {
30
- options ??= {};
31
- options.buildTargetName ??= 'build';
32
- options.serveTargetName ??= 'serve';
33
- options.serveStaticTargetName ??= 'serve-static';
34
- options.previewTargetName ??= 'preview';
35
- const projectRoot = (0, path_1.dirname)(configFilePath);
36
- // Do not create a project if package.json and project.json isn't there.
37
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
38
- if (!siblingFiles.includes('package.json') &&
39
- !siblingFiles.includes('project.json')) {
40
- return {};
41
- }
42
- const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
43
- (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
44
- ]);
45
- const targets = targetsCache[hash]
46
- ? targetsCache[hash]
47
- : await createWebpackTargets(configFilePath, projectRoot, options, context);
48
- return {
49
- projects: {
50
- [projectRoot]: {
51
- projectType: 'application',
52
- targets,
53
- },
54
- },
55
- };
56
- },
57
- ];
58
- async function createWebpackTargets(configFilePath, projectRoot, options, context) {
59
- const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
60
- const webpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
61
- const webpackOptions = await (0, read_webpack_options_1.readWebpackOptions)(webpackConfig);
62
- const outputPath = normalizeOutputPath(webpackOptions.output?.path, projectRoot);
63
- const targets = {};
64
- targets[options.buildTargetName] = {
65
- command: `webpack-cli build`,
66
- options: { cwd: projectRoot, args: ['--node-env=production'] },
67
- cache: true,
68
- dependsOn: [`^${options.buildTargetName}`],
69
- inputs: 'production' in namedInputs
70
- ? [
71
- 'production',
72
- '^production',
73
- {
74
- externalDependencies: ['webpack-cli'],
75
- },
76
- ]
77
- : [
78
- 'default',
79
- '^default',
80
- {
81
- externalDependencies: ['webpack-cli'],
82
- },
83
- ],
84
- outputs: [outputPath],
85
- };
86
- targets[options.serveTargetName] = {
87
- command: `webpack-cli serve`,
88
- options: {
89
- cwd: projectRoot,
90
- args: ['--node-env=development'],
91
- },
92
- };
93
- targets[options.previewTargetName] = {
94
- command: `webpack-cli serve`,
95
- options: {
96
- cwd: projectRoot,
97
- args: ['--node-env=production'],
98
- },
99
- };
100
- targets[options.serveStaticTargetName] = {
101
- executor: '@nx/web:file-server',
102
- options: {
103
- buildTarget: options.buildTargetName,
104
- spa: true,
105
- },
106
- };
107
- return targets;
108
- }
109
- function normalizeOutputPath(outputPath, projectRoot) {
110
- if (!outputPath) {
111
- // If outputPath is undefined, use webpack's default `dist` directory.
112
- if (projectRoot === '.') {
113
- return `{projectRoot}/dist}`;
114
- }
115
- else {
116
- return `{workspaceRoot}/dist/{projectRoot}`;
117
- }
118
- }
119
- else {
120
- if ((0, path_1.isAbsolute)(outputPath)) {
121
- return `{workspaceRoot}/${(0, path_1.relative)(devkit_1.workspaceRoot, outputPath)}`;
122
- }
123
- else {
124
- if (outputPath.startsWith('..')) {
125
- return (0, path_1.join)('{workspaceRoot}', (0, path_1.join)(projectRoot, outputPath));
126
- }
127
- else {
128
- return (0, path_1.join)('{projectRoot}', outputPath);
129
- }
130
- }
131
- }
132
- }
@@ -1,6 +0,0 @@
1
- import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
- export type EnsureDependenciesOptions = {
3
- compiler?: 'swc' | 'tsc';
4
- uiFramework?: 'none' | 'react';
5
- };
6
- export declare function ensureDependencies(tree: Tree, options: EnsureDependenciesOptions): GeneratorCallback;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureDependencies = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
6
- const versions_1 = require("./versions");
7
- function ensureDependencies(tree, options) {
8
- const tasks = [];
9
- const devDependencies = {};
10
- if (options.compiler === 'swc') {
11
- devDependencies['swc-loader'] = versions_1.swcLoaderVersion;
12
- const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(tree);
13
- tasks.push(addSwcTask);
14
- }
15
- if (options.compiler === 'tsc') {
16
- devDependencies['tslib'] = versions_1.tsLibVersion;
17
- }
18
- if (options.uiFramework === 'react') {
19
- devDependencies['@pmmmwh/react-refresh-webpack-plugin'] =
20
- versions_1.reactRefreshWebpackPluginVersion;
21
- devDependencies['@svgr/webpack'] = versions_1.svgrWebpackVersion;
22
- devDependencies['react-refresh'] = versions_1.reactRefreshVersion;
23
- devDependencies['url-loader'] = versions_1.urlLoaderVersion;
24
- }
25
- tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies));
26
- return (0, devkit_1.runTasksInSerial)(...tasks);
27
- }
28
- exports.ensureDependencies = ensureDependencies;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function hasPlugin(tree: Tree): boolean;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasPlugin = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- function hasPlugin(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
- return !!nxJson.plugins?.some((p) => typeof p === 'string'
8
- ? p === '@nx/webpack/plugin'
9
- : p.plugin === '@nx/webpack/plugin');
10
- }
11
- exports.hasPlugin = hasPlugin;
@@ -1,10 +0,0 @@
1
- import { Configuration } from 'webpack';
2
- /**
3
- * Reads the webpack options from a give webpack configuration. The configuration can be:
4
- * 1. A standard config object
5
- * 2. A standard function that returns a config object (webpack.js.org/configuration/configuration-types/#exporting-a-function)
6
- * 3. A Nx-specific composable function that takes Nx context, webpack config, and returns the config object.
7
- *
8
- * @param webpackConfig
9
- */
10
- export declare function readWebpackOptions(webpackConfig: unknown): Promise<Configuration>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readWebpackOptions = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const config_1 = require("../config");
6
- /**
7
- * Reads the webpack options from a give webpack configuration. The configuration can be:
8
- * 1. A standard config object
9
- * 2. A standard function that returns a config object (webpack.js.org/configuration/configuration-types/#exporting-a-function)
10
- * 3. A Nx-specific composable function that takes Nx context, webpack config, and returns the config object.
11
- *
12
- * @param webpackConfig
13
- */
14
- async function readWebpackOptions(webpackConfig) {
15
- let config;
16
- if ((0, config_1.isNxWebpackComposablePlugin)(webpackConfig)) {
17
- config = await webpackConfig({}, {
18
- // These values are only used during build-time, so passing stubs here just to read out
19
- // the returned config object.
20
- options: {
21
- root: devkit_1.workspaceRoot,
22
- projectRoot: '',
23
- sourceRoot: '',
24
- outputFileName: undefined,
25
- outputPath: undefined,
26
- assets: undefined,
27
- },
28
- context: { root: devkit_1.workspaceRoot, cwd: undefined, isVerbose: false },
29
- });
30
- }
31
- else if (typeof webpackConfig === 'function') {
32
- config = await webpackConfig({
33
- production: true, // we want the production build options
34
- }, {});
35
- }
36
- else {
37
- config = webpackConfig;
38
- }
39
- return config;
40
- }
41
- exports.readWebpackOptions = readWebpackOptions;
@@ -1,3 +0,0 @@
1
- export declare function resolveUserDefinedWebpackConfig(path: string, tsConfig: string,
2
- /** Skip require cache and return latest content */
3
- reload?: boolean): any;