@nx/webpack 0.0.0-pr-22179-271588f
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 +22 -0
- package/README.md +68 -0
- package/executors.json +19 -0
- package/generators.json +20 -0
- package/index.d.ts +18 -0
- package/index.js +24 -0
- package/migrations.json +60 -0
- package/package.json +74 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/src/executors/dev-server/dev-server.impl.d.ts +7 -0
- package/src/executors/dev-server/dev-server.impl.js +79 -0
- package/src/executors/dev-server/lib/get-dev-server-config.d.ts +4 -0
- package/src/executors/dev-server/lib/get-dev-server-config.js +79 -0
- package/src/executors/dev-server/lib/serve-path.d.ts +3 -0
- package/src/executors/dev-server/lib/serve-path.js +45 -0
- package/src/executors/dev-server/schema.d.ts +17 -0
- package/src/executors/dev-server/schema.json +76 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +1 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +39 -0
- package/src/executors/ssr-dev-server/schema.d.ts +11 -0
- package/src/executors/ssr-dev-server/schema.json +37 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +8 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +39 -0
- package/src/executors/webpack/lib/normalize-options.d.ts +3 -0
- package/src/executors/webpack/lib/normalize-options.js +40 -0
- package/src/executors/webpack/lib/run-webpack.d.ts +3 -0
- package/src/executors/webpack/lib/run-webpack.js +36 -0
- package/src/executors/webpack/schema.d.ts +96 -0
- package/src/executors/webpack/schema.json +394 -0
- package/src/executors/webpack/webpack.impl.d.ts +13 -0
- package/src/executors/webpack/webpack.impl.js +125 -0
- package/src/generators/configuration/configuration.d.ts +5 -0
- package/src/generators/configuration/configuration.js +194 -0
- package/src/generators/configuration/schema.d.ts +14 -0
- package/src/generators/configuration/schema.json +77 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +60 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
- package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.d.ts +2 -0
- package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.js +20 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-15-6-3/webpack-config-setup.js +100 -0
- package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.d.ts +2 -0
- package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.js +17 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-17-2-1/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-17-2-1/webpack-config-setup.js +31 -0
- package/src/plugins/generate-package-json-plugin.d.ts +14 -0
- package/src/plugins/generate-package-json-plugin.js +44 -0
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +8 -0
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +31 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +5 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +318 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +5 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +372 -0
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +53 -0
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +78 -0
- package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +1 -0
- package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +35 -0
- package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +3 -0
- package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +42 -0
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +4 -0
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +143 -0
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +73 -0
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +117 -0
- package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.d.ts +216 -0
- package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.js +2 -0
- package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.d.ts +17 -0
- package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.js +48 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +131 -0
- package/src/plugins/stats-json-plugin.d.ts +4 -0
- package/src/plugins/stats-json-plugin.js +13 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +11 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.js +85 -0
- package/src/plugins/write-index-html-plugin.d.ts +22 -0
- package/src/plugins/write-index-html-plugin.js +249 -0
- package/src/utils/config.d.ts +22 -0
- package/src/utils/config.js +66 -0
- package/src/utils/create-copy-plugin.d.ts +3 -0
- package/src/utils/create-copy-plugin.js +26 -0
- package/src/utils/ensure-dependencies.d.ts +6 -0
- package/src/utils/ensure-dependencies.js +28 -0
- package/src/utils/fs.d.ts +6 -0
- package/src/utils/fs.js +58 -0
- package/src/utils/get-client-environment.d.ts +5 -0
- package/src/utils/get-client-environment.js +29 -0
- package/src/utils/get-css-module-local-ident.d.ts +1 -0
- package/src/utils/get-css-module-local-ident.js +18 -0
- package/src/utils/has-plugin.d.ts +2 -0
- package/src/utils/has-plugin.js +11 -0
- package/src/utils/hash-format.d.ts +7 -0
- package/src/utils/hash-format.js +23 -0
- package/src/utils/models.d.ts +23 -0
- package/src/utils/models.js +2 -0
- package/src/utils/module-federation/dependencies.d.ts +6 -0
- package/src/utils/module-federation/dependencies.js +57 -0
- package/src/utils/module-federation/get-remotes-for-host.d.ts +14 -0
- package/src/utils/module-federation/get-remotes-for-host.js +88 -0
- package/src/utils/module-federation/index.d.ts +6 -0
- package/src/utils/module-federation/index.js +9 -0
- package/src/utils/module-federation/models/index.d.ts +39 -0
- package/src/utils/module-federation/models/index.js +2 -0
- package/src/utils/module-federation/package-json.d.ts +8 -0
- package/src/utils/module-federation/package-json.js +13 -0
- package/src/utils/module-federation/public-api.d.ts +6 -0
- package/src/utils/module-federation/public-api.js +16 -0
- package/src/utils/module-federation/remotes.d.ts +19 -0
- package/src/utils/module-federation/remotes.js +80 -0
- package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
- package/src/utils/module-federation/secondary-entry-points.js +108 -0
- package/src/utils/module-federation/share.d.ts +48 -0
- package/src/utils/module-federation/share.js +215 -0
- package/src/utils/module-federation/typescript.d.ts +4 -0
- package/src/utils/module-federation/typescript.js +54 -0
- package/src/utils/run-webpack.d.ts +5 -0
- package/src/utils/run-webpack.js +31 -0
- package/src/utils/versions.d.ts +8 -0
- package/src/utils/versions.js +12 -0
- package/src/utils/web-babel-loader.d.ts +0 -0
- package/src/utils/web-babel-loader.js +17 -0
- package/src/utils/webpack/deprecated-stylus-loader.d.ts +1 -0
- package/src/utils/webpack/deprecated-stylus-loader.js +11 -0
- package/src/utils/webpack/interpolate-env-variables-to-index.d.ts +1 -0
- package/src/utils/webpack/interpolate-env-variables-to-index.js +30 -0
- package/src/utils/webpack/normalize-entry.d.ts +2 -0
- package/src/utils/webpack/normalize-entry.js +28 -0
- package/src/utils/webpack/package-chunk-sort.d.ts +5 -0
- package/src/utils/webpack/package-chunk-sort.js +29 -0
- package/src/utils/webpack/plugins/postcss-cli-resources.d.ts +13 -0
- package/src/utils/webpack/plugins/postcss-cli-resources.js +165 -0
- package/src/utils/webpack/plugins/scripts-webpack-plugin.d.ts +17 -0
- package/src/utils/webpack/plugins/scripts-webpack-plugin.js +119 -0
- package/src/utils/webpack/read-webpack-options.d.ts +10 -0
- package/src/utils/webpack/read-webpack-options.js +41 -0
- package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts +3 -0
- package/src/utils/webpack/resolve-user-defined-webpack-config.js +39 -0
- package/src/utils/with-nx.d.ts +8 -0
- package/src/utils/with-nx.js +34 -0
- package/src/utils/with-web.d.ts +22 -0
- package/src/utils/with-web.js +26 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"title": "Webpack builder",
|
|
5
|
+
"description": "Build a project using webpack.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"crossOrigin": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The `crossorigin` attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'."
|
|
12
|
+
},
|
|
13
|
+
"main": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "The name of the main entry-point file.",
|
|
16
|
+
"x-completion-type": "file",
|
|
17
|
+
"x-completion-glob": "**/*@(.js|.ts|.tsx)",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"tsConfig": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The name of the Typescript configuration file.",
|
|
23
|
+
"x-completion-type": "file",
|
|
24
|
+
"x-completion-glob": "tsconfig.*.json",
|
|
25
|
+
"x-priority": "important"
|
|
26
|
+
},
|
|
27
|
+
"compiler": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The compiler to use.",
|
|
30
|
+
"enum": ["babel", "swc", "tsc"]
|
|
31
|
+
},
|
|
32
|
+
"outputPath": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "The output path of the generated files.",
|
|
35
|
+
"x-completion-type": "directory",
|
|
36
|
+
"x-priority": "important"
|
|
37
|
+
},
|
|
38
|
+
"target": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"alias": "platform",
|
|
41
|
+
"description": "Target platform for the build, same as the Webpack target option.",
|
|
42
|
+
"enum": ["node", "web", "webworker"]
|
|
43
|
+
},
|
|
44
|
+
"deleteOutputPath": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "Delete the output path before building.",
|
|
47
|
+
"default": true
|
|
48
|
+
},
|
|
49
|
+
"watch": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "Enable re-building when files change."
|
|
52
|
+
},
|
|
53
|
+
"baseHref": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "Base url for the application being built."
|
|
56
|
+
},
|
|
57
|
+
"deployUrl": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "URL where the application will be deployed."
|
|
60
|
+
},
|
|
61
|
+
"vendorChunk": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "Use a separate bundle containing only vendor libraries."
|
|
64
|
+
},
|
|
65
|
+
"commonChunk": {
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"description": "Use a separate bundle containing code used across multiple bundles."
|
|
68
|
+
},
|
|
69
|
+
"runtimeChunk": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"description": "Use a separate bundle containing the runtime."
|
|
72
|
+
},
|
|
73
|
+
"sourceMap": {
|
|
74
|
+
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
|
|
75
|
+
"oneOf": [
|
|
76
|
+
{
|
|
77
|
+
"type": "boolean"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "string"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"progress": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"description": "Log progress to the console while building."
|
|
87
|
+
},
|
|
88
|
+
"assets": {
|
|
89
|
+
"type": "array",
|
|
90
|
+
"description": "List of static application assets.",
|
|
91
|
+
"items": {
|
|
92
|
+
"$ref": "#/definitions/assetPattern"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"index": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "HTML File which will be contain the application.",
|
|
98
|
+
"x-completion-type": "file",
|
|
99
|
+
"x-completion-glob": "**/*@(.html|.htm)"
|
|
100
|
+
},
|
|
101
|
+
"scripts": {
|
|
102
|
+
"type": "array",
|
|
103
|
+
"description": "External Scripts which will be included before the main application entry.",
|
|
104
|
+
"items": {
|
|
105
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"styles": {
|
|
109
|
+
"type": "array",
|
|
110
|
+
"description": "External Styles which will be included with the application",
|
|
111
|
+
"items": {
|
|
112
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"namedChunks": {
|
|
116
|
+
"type": "boolean",
|
|
117
|
+
"description": "Names the produced bundles according to their entry file."
|
|
118
|
+
},
|
|
119
|
+
"outputHashing": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"description": "Define the output filename cache-busting hashing mode.",
|
|
122
|
+
"enum": ["none", "all", "media", "bundles"]
|
|
123
|
+
},
|
|
124
|
+
"stylePreprocessorOptions": {
|
|
125
|
+
"description": "Options to pass to style preprocessors.",
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"includePaths": {
|
|
129
|
+
"description": "Paths to include. Paths will be resolved to project root.",
|
|
130
|
+
"type": "array",
|
|
131
|
+
"items": {
|
|
132
|
+
"type": "string"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"additionalProperties": false
|
|
137
|
+
},
|
|
138
|
+
"optimization": {
|
|
139
|
+
"description": "Enables optimization of the build output.",
|
|
140
|
+
"oneOf": [
|
|
141
|
+
{
|
|
142
|
+
"type": "object",
|
|
143
|
+
"properties": {
|
|
144
|
+
"scripts": {
|
|
145
|
+
"type": "boolean",
|
|
146
|
+
"description": "Enables optimization of the scripts output.",
|
|
147
|
+
"default": true
|
|
148
|
+
},
|
|
149
|
+
"styles": {
|
|
150
|
+
"type": "boolean",
|
|
151
|
+
"description": "Enables optimization of the styles output.",
|
|
152
|
+
"default": true
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"additionalProperties": false
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"generatePackageJson": {
|
|
163
|
+
"type": "boolean",
|
|
164
|
+
"description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated."
|
|
165
|
+
},
|
|
166
|
+
"transformers": {
|
|
167
|
+
"type": "array",
|
|
168
|
+
"description": "List of TypeScript Compiler Transfomers Plugins.",
|
|
169
|
+
"aliases": ["tsPlugins"],
|
|
170
|
+
"items": {
|
|
171
|
+
"$ref": "#/definitions/transformerPattern"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"additionalEntryPoints": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"properties": {
|
|
179
|
+
"entryName": {
|
|
180
|
+
"type": "string",
|
|
181
|
+
"description": "Name of the additional entry file."
|
|
182
|
+
},
|
|
183
|
+
"entryPath": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"description": "Path to the additional entry file.",
|
|
186
|
+
"x-completion-type": "file",
|
|
187
|
+
"x-completion-glob": "**/*@(.js|.ts)"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"outputFileName": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"description": "Name of the main output file.",
|
|
195
|
+
"default": "main.js"
|
|
196
|
+
},
|
|
197
|
+
"externalDependencies": {
|
|
198
|
+
"oneOf": [
|
|
199
|
+
{
|
|
200
|
+
"type": "string",
|
|
201
|
+
"enum": ["none", "all"]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"type": "array",
|
|
205
|
+
"items": {
|
|
206
|
+
"type": "string"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"description": "Dependencies to keep external to the bundle. (`all` (default), `none`, or an array of module names)"
|
|
211
|
+
},
|
|
212
|
+
"extractCss": {
|
|
213
|
+
"type": "boolean",
|
|
214
|
+
"description": "Extract CSS into a `.css` file."
|
|
215
|
+
},
|
|
216
|
+
"subresourceIntegrity": {
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"description": "Enables the use of subresource integrity validation."
|
|
219
|
+
},
|
|
220
|
+
"polyfills": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"description": "Polyfills to load before application",
|
|
223
|
+
"x-completion-type": "file",
|
|
224
|
+
"x-completion-glob": "**/*@(.js|.ts|.tsx)"
|
|
225
|
+
},
|
|
226
|
+
"verbose": {
|
|
227
|
+
"type": "boolean",
|
|
228
|
+
"description": "Emits verbose output"
|
|
229
|
+
},
|
|
230
|
+
"statsJson": {
|
|
231
|
+
"type": "boolean",
|
|
232
|
+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or `<https://webpack.github.io/analyse>`."
|
|
233
|
+
},
|
|
234
|
+
"isolatedConfig": {
|
|
235
|
+
"type": "boolean",
|
|
236
|
+
"description": "Do not apply Nx webpack plugins automatically. Plugins need to be applied in the project's webpack.config.js file (e.g. withNx, withReact, etc.).",
|
|
237
|
+
"default": true,
|
|
238
|
+
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 19. See https://nx.dev/recipes/webpack/webpack-config-setup."
|
|
239
|
+
},
|
|
240
|
+
"standardWebpackConfigFunction": {
|
|
241
|
+
"type": "boolean",
|
|
242
|
+
"description": "Set to true if the webpack config exports a standard webpack function, not an Nx-specific one. See: https://webpack.js.org/configuration/configuration-types/#exporting-a-function",
|
|
243
|
+
"default": false
|
|
244
|
+
},
|
|
245
|
+
"extractLicenses": {
|
|
246
|
+
"type": "boolean",
|
|
247
|
+
"description": "Extract all licenses in a separate file, in the case of production builds only."
|
|
248
|
+
},
|
|
249
|
+
"memoryLimit": {
|
|
250
|
+
"type": "number",
|
|
251
|
+
"description": "Memory limit for type checking service process in `MB`."
|
|
252
|
+
},
|
|
253
|
+
"fileReplacements": {
|
|
254
|
+
"description": "Replace files with other files in the build.",
|
|
255
|
+
"type": "array",
|
|
256
|
+
"items": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"properties": {
|
|
259
|
+
"replace": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"description": "The file to be replaced.",
|
|
262
|
+
"x-completion-type": "file"
|
|
263
|
+
},
|
|
264
|
+
"with": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"description": "The file to replace with.",
|
|
267
|
+
"x-completion-type": "file"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"additionalProperties": false,
|
|
271
|
+
"required": ["replace", "with"]
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"buildLibsFromSource": {
|
|
275
|
+
"type": "boolean",
|
|
276
|
+
"description": "Read buildable libraries from source instead of building them separately. If set to `false`, the `tsConfig` option must also be set to remap paths.",
|
|
277
|
+
"default": true
|
|
278
|
+
},
|
|
279
|
+
"generateIndexHtml": {
|
|
280
|
+
"type": "boolean",
|
|
281
|
+
"description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`."
|
|
282
|
+
},
|
|
283
|
+
"postcssConfig": {
|
|
284
|
+
"type": "string",
|
|
285
|
+
"description": "Set a path to PostCSS config that applies to the app and all libs. Defaults to `undefined`, which auto-detects postcss.config.js files in each `app`/`lib` directory."
|
|
286
|
+
},
|
|
287
|
+
"webpackConfig": {
|
|
288
|
+
"type": "string",
|
|
289
|
+
"description": "Path to a function which takes a webpack config, some context and returns the resulting webpack config. See https://nx.dev/guides/customize-webpack",
|
|
290
|
+
"x-completion-type": "file",
|
|
291
|
+
"x-completion-glob": "webpack?(*)@(.js|.ts)",
|
|
292
|
+
"x-priority": "important"
|
|
293
|
+
},
|
|
294
|
+
"babelUpwardRootMode": {
|
|
295
|
+
"type": "boolean",
|
|
296
|
+
"description": "Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode"
|
|
297
|
+
},
|
|
298
|
+
"babelConfig": {
|
|
299
|
+
"type": "string",
|
|
300
|
+
"description": "Path to the babel configuration file of your project. If not provided, Nx will default to the .babelrc file at the root of your project. See https://babeljs.io/docs/en/config-files",
|
|
301
|
+
"x-completion-type": "file"
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"required": [],
|
|
305
|
+
"definitions": {
|
|
306
|
+
"assetPattern": {
|
|
307
|
+
"oneOf": [
|
|
308
|
+
{
|
|
309
|
+
"type": "object",
|
|
310
|
+
"properties": {
|
|
311
|
+
"glob": {
|
|
312
|
+
"type": "string",
|
|
313
|
+
"description": "The pattern to match."
|
|
314
|
+
},
|
|
315
|
+
"input": {
|
|
316
|
+
"type": "string",
|
|
317
|
+
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
|
|
318
|
+
},
|
|
319
|
+
"ignore": {
|
|
320
|
+
"description": "An array of globs to ignore.",
|
|
321
|
+
"type": "array",
|
|
322
|
+
"items": {
|
|
323
|
+
"type": "string"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"output": {
|
|
327
|
+
"type": "string",
|
|
328
|
+
"description": "Absolute path within the output."
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
"additionalProperties": false,
|
|
332
|
+
"required": ["glob", "input", "output"]
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"type": "string"
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
},
|
|
339
|
+
"extraEntryPoint": {
|
|
340
|
+
"oneOf": [
|
|
341
|
+
{
|
|
342
|
+
"type": "object",
|
|
343
|
+
"properties": {
|
|
344
|
+
"input": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"description": "The file to include.",
|
|
347
|
+
"x-completion-type": "file",
|
|
348
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
349
|
+
},
|
|
350
|
+
"bundleName": {
|
|
351
|
+
"type": "string",
|
|
352
|
+
"description": "The bundle name for this extra entry point."
|
|
353
|
+
},
|
|
354
|
+
"inject": {
|
|
355
|
+
"type": "boolean",
|
|
356
|
+
"description": "If the bundle will be referenced in the HTML file.",
|
|
357
|
+
"default": true
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"additionalProperties": false,
|
|
361
|
+
"required": ["input"]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"type": "string",
|
|
365
|
+
"description": "The file to include.",
|
|
366
|
+
"x-completion-type": "file",
|
|
367
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
},
|
|
371
|
+
"transformerPattern": {
|
|
372
|
+
"oneOf": [
|
|
373
|
+
{
|
|
374
|
+
"type": "string"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"type": "object",
|
|
378
|
+
"properties": {
|
|
379
|
+
"name": {
|
|
380
|
+
"type": "string"
|
|
381
|
+
},
|
|
382
|
+
"options": {
|
|
383
|
+
"type": "object",
|
|
384
|
+
"additionalProperties": true
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
"additionalProperties": false,
|
|
388
|
+
"required": ["name"]
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"examplesFile": "../../../docs/webpack-build-executor-examples.md"
|
|
394
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { WebpackExecutorOptions } from './schema';
|
|
3
|
+
export type WebpackExecutorEvent = {
|
|
4
|
+
success: false;
|
|
5
|
+
outfile?: string;
|
|
6
|
+
options?: WebpackExecutorOptions;
|
|
7
|
+
} | {
|
|
8
|
+
success: true;
|
|
9
|
+
outfile: string;
|
|
10
|
+
options?: WebpackExecutorOptions;
|
|
11
|
+
};
|
|
12
|
+
export declare function webpackExecutor(_options: WebpackExecutorOptions, context: ExecutorContext): AsyncGenerator<WebpackExecutorEvent, WebpackExecutorEvent, undefined>;
|
|
13
|
+
export default webpackExecutor;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webpackExecutor = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const operators_1 = require("rxjs/operators");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
10
|
+
const run_webpack_1 = require("./lib/run-webpack");
|
|
11
|
+
const fs_1 = require("../../utils/fs");
|
|
12
|
+
const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
|
|
13
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
14
|
+
const config_1 = require("../../utils/config");
|
|
15
|
+
const with_nx_1 = require("../../utils/with-nx");
|
|
16
|
+
const js_1 = require("@nx/js");
|
|
17
|
+
const with_web_1 = require("../../utils/with-web");
|
|
18
|
+
async function getWebpackConfigs(options, context) {
|
|
19
|
+
if (options.isolatedConfig && !options.webpackConfig) {
|
|
20
|
+
throw new Error(`Using "isolatedConfig" without a "webpackConfig" is not supported.`);
|
|
21
|
+
}
|
|
22
|
+
let userDefinedWebpackConfig = null;
|
|
23
|
+
if (options.webpackConfig) {
|
|
24
|
+
userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(options.webpackConfig, (0, js_1.getRootTsConfigPath)());
|
|
25
|
+
if (typeof userDefinedWebpackConfig.then === 'function') {
|
|
26
|
+
userDefinedWebpackConfig = await userDefinedWebpackConfig;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const config = options.isolatedConfig
|
|
30
|
+
? {}
|
|
31
|
+
: (options.target === 'web'
|
|
32
|
+
? (0, config_1.composePluginsSync)((0, with_nx_1.withNx)(options), (0, with_web_1.withWeb)(options))
|
|
33
|
+
: (0, with_nx_1.withNx)(options))({}, { options, context });
|
|
34
|
+
if (typeof userDefinedWebpackConfig === 'function' &&
|
|
35
|
+
((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
|
|
36
|
+
!options.standardWebpackConfigFunction)) {
|
|
37
|
+
// Old behavior, call the Nx-specific webpack config function that user exports
|
|
38
|
+
return await userDefinedWebpackConfig(config, {
|
|
39
|
+
options,
|
|
40
|
+
context,
|
|
41
|
+
configuration: context.configurationName, // backwards compat
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (userDefinedWebpackConfig) {
|
|
45
|
+
// New behavior, we want the webpack config to export object
|
|
46
|
+
return userDefinedWebpackConfig;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Fallback case, if we cannot find a webpack config path
|
|
50
|
+
return config;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function* webpackExecutor(_options, context) {
|
|
54
|
+
// Default to production build.
|
|
55
|
+
process.env['NODE_ENV'] ||= 'production';
|
|
56
|
+
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
57
|
+
const sourceRoot = metadata.sourceRoot;
|
|
58
|
+
const options = (0, normalize_options_1.normalizeOptions)(_options, context.root, metadata.root, sourceRoot);
|
|
59
|
+
const isScriptOptimizeOn = typeof options.optimization === 'boolean'
|
|
60
|
+
? options.optimization
|
|
61
|
+
: options.optimization && options.optimization.scripts
|
|
62
|
+
? options.optimization.scripts
|
|
63
|
+
: false;
|
|
64
|
+
process.env.NODE_ENV ||= isScriptOptimizeOn
|
|
65
|
+
? 'production'
|
|
66
|
+
: 'development';
|
|
67
|
+
process.env.NX_BUILD_LIBS_FROM_SOURCE = `${options.buildLibsFromSource}`;
|
|
68
|
+
process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({
|
|
69
|
+
project: context.projectName,
|
|
70
|
+
target: context.targetName,
|
|
71
|
+
configuration: context.configurationName,
|
|
72
|
+
});
|
|
73
|
+
if (options.compiler === 'swc') {
|
|
74
|
+
try {
|
|
75
|
+
require.resolve('swc-loader');
|
|
76
|
+
require.resolve('@swc/core');
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
devkit_1.logger.error(`Missing SWC dependencies: @swc/core, swc-loader. Make sure you install them first.`);
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
options,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!options.buildLibsFromSource && context.targetName) {
|
|
87
|
+
const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName);
|
|
88
|
+
options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, context.root, metadata.root, dependencies);
|
|
89
|
+
process.env.NX_TSCONFIG_PATH = options.tsConfig;
|
|
90
|
+
}
|
|
91
|
+
// Delete output path before bundling
|
|
92
|
+
if (options.deleteOutputPath && options.outputPath) {
|
|
93
|
+
(0, fs_1.deleteOutputDir)(context.root, options.outputPath);
|
|
94
|
+
}
|
|
95
|
+
if (options.generatePackageJson && metadata.projectType !== 'application') {
|
|
96
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.
|
|
97
|
+
For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).`);
|
|
98
|
+
}
|
|
99
|
+
const configs = await getWebpackConfigs(options, context);
|
|
100
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)((0, rxjs_1.of)(configs).pipe((0, operators_1.mergeMap)((config) => (Array.isArray(config) ? (0, rxjs_1.from)(config) : (0, rxjs_1.of)(config))),
|
|
101
|
+
// Run build sequentially and bail when first one fails.
|
|
102
|
+
(0, operators_1.mergeScan)((acc, config) => {
|
|
103
|
+
if (!acc.hasErrors()) {
|
|
104
|
+
return (0, run_webpack_1.runWebpack)(config).pipe((0, operators_1.tap)((stats) => {
|
|
105
|
+
console.info(stats.toString(config.stats));
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return (0, rxjs_1.of)();
|
|
110
|
+
}
|
|
111
|
+
}, { hasErrors: () => false }, 1),
|
|
112
|
+
// Collect build results as an array.
|
|
113
|
+
(0, operators_1.bufferCount)(Array.isArray(configs) ? configs.length : 1), (0, operators_1.switchMap)(async (results) => {
|
|
114
|
+
const success = results.every((result) => Boolean(result) && !result.hasErrors());
|
|
115
|
+
// TODO(jack): This should read output from webpack config if provided.
|
|
116
|
+
// The outfile is only used by NestJS, where `@nx/js:node` executor requires it to run the file.
|
|
117
|
+
return {
|
|
118
|
+
success,
|
|
119
|
+
outfile: (0, path_1.resolve)(context.root, options.outputPath, options.outputFileName),
|
|
120
|
+
options,
|
|
121
|
+
};
|
|
122
|
+
})));
|
|
123
|
+
}
|
|
124
|
+
exports.webpackExecutor = webpackExecutor;
|
|
125
|
+
exports.default = webpackExecutor;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { ConfigurationGeneratorSchema } from './schema';
|
|
3
|
+
export declare function configurationGenerator(tree: Tree, options: ConfigurationGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function configurationGeneratorInternal(tree: Tree, options: ConfigurationGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
|
+
export default configurationGenerator;
|