@nx/webpack 17.1.0-beta.4 → 17.1.0-beta.5

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 (33) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +5 -1
  3. package/package.json +4 -4
  4. package/src/executors/dev-server/dev-server.impl.js +18 -5
  5. package/src/executors/webpack/lib/normalize-options.d.ts +1 -2
  6. package/src/executors/webpack/lib/normalize-options.js +3 -52
  7. package/src/executors/webpack/schema.d.ts +4 -4
  8. package/src/executors/webpack/webpack.impl.js +11 -4
  9. package/src/plugins/generate-package-json-plugin.d.ts +6 -4
  10. package/src/plugins/generate-package-json-plugin.js +11 -14
  11. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +8 -0
  12. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +31 -0
  13. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +3 -0
  14. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +288 -0
  15. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +3 -0
  16. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +355 -0
  17. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +53 -0
  18. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +78 -0
  19. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +1 -0
  20. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +35 -0
  21. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +3 -0
  22. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +42 -0
  23. package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +3 -0
  24. package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +116 -0
  25. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +73 -0
  26. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +115 -0
  27. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.d.ts +87 -0
  28. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.js +2 -0
  29. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.d.ts +18 -0
  30. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.js +52 -0
  31. package/src/utils/with-nx.d.ts +0 -53
  32. package/src/utils/with-nx.js +14 -361
  33. package/src/utils/with-web.js +9 -488
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyWebConfig = void 0;
4
+ const path = require("path");
5
+ const webpack_subresource_integrity_1 = require("webpack-subresource-integrity");
6
+ const webpack_1 = require("webpack");
7
+ const write_index_html_plugin_1 = require("../../write-index-html-plugin");
8
+ const hash_format_1 = require("../../../utils/hash-format");
9
+ const get_client_environment_1 = require("../../../utils/get-client-environment");
10
+ const normalize_entry_1 = require("../../../utils/webpack/normalize-entry");
11
+ const stylesheet_loaders_1 = require("./stylesheet-loaders");
12
+ const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
13
+ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
14
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
15
+ function applyWebConfig(options, config = {}) {
16
+ const plugins = [];
17
+ const stylesOptimization = typeof options.optimization === 'object'
18
+ ? options.optimization.styles
19
+ : options.optimization;
20
+ if (Array.isArray(options.scripts)) {
21
+ plugins.push(...(0, instantiate_script_plugins_1.instantiateScriptPlugins)(options));
22
+ }
23
+ if (options.index && options.generateIndexHtml) {
24
+ plugins.push(new write_index_html_plugin_1.WriteIndexHtmlPlugin({
25
+ crossOrigin: options.crossOrigin,
26
+ sri: options.subresourceIntegrity,
27
+ outputPath: path.basename(options.index),
28
+ indexPath: path.join(options.root, options.index),
29
+ baseHref: options.baseHref,
30
+ deployUrl: options.deployUrl,
31
+ scripts: options.scripts,
32
+ styles: options.styles,
33
+ }));
34
+ }
35
+ if (options.subresourceIntegrity) {
36
+ plugins.push(new webpack_subresource_integrity_1.SubresourceIntegrityPlugin());
37
+ }
38
+ const minimizer = [new webpack_1.ids.HashedModuleIdsPlugin()];
39
+ if (stylesOptimization) {
40
+ minimizer.push(new CssMinimizerPlugin({
41
+ test: /\.(?:css|scss|sass|less|styl)$/,
42
+ }));
43
+ }
44
+ if (!options.ssr) {
45
+ plugins.push(new webpack_1.DefinePlugin((0, get_client_environment_1.getClientEnvironment)(process.env.NODE_ENV).stringified));
46
+ }
47
+ const entry = {};
48
+ const globalStylePaths = [];
49
+ // Determine hashing format.
50
+ const hashFormat = (0, hash_format_1.getOutputHashFormat)(options.outputHashing);
51
+ const includePaths = [];
52
+ if (options?.stylePreprocessorOptions?.includePaths?.length > 0) {
53
+ options.stylePreprocessorOptions.includePaths.forEach((includePath) => includePaths.push(path.resolve(options.root, includePath)));
54
+ }
55
+ let lessPathOptions = {};
56
+ if (includePaths.length > 0) {
57
+ lessPathOptions = {
58
+ paths: includePaths,
59
+ };
60
+ }
61
+ // Process global styles.
62
+ if (options.styles.length > 0) {
63
+ (0, normalize_entry_1.normalizeExtraEntryPoints)(options.styles, 'styles').forEach((style) => {
64
+ const resolvedPath = path.resolve(options.root, style.input);
65
+ // Add style entry points.
66
+ if (entry[style.bundleName]) {
67
+ entry[style.bundleName].import.push(resolvedPath);
68
+ }
69
+ else {
70
+ entry[style.bundleName] = { import: [resolvedPath] };
71
+ }
72
+ // Add global css paths.
73
+ globalStylePaths.push(resolvedPath);
74
+ });
75
+ }
76
+ const cssModuleRules = [
77
+ {
78
+ test: /\.module\.css$/,
79
+ exclude: globalStylePaths,
80
+ use: (0, stylesheet_loaders_1.getCommonLoadersForCssModules)(options, includePaths),
81
+ },
82
+ {
83
+ test: /\.module\.(scss|sass)$/,
84
+ exclude: globalStylePaths,
85
+ use: [
86
+ ...(0, stylesheet_loaders_1.getCommonLoadersForCssModules)(options, includePaths),
87
+ {
88
+ loader: require.resolve('sass-loader'),
89
+ options: {
90
+ implementation: require('sass'),
91
+ sassOptions: {
92
+ fiber: false,
93
+ precision: 8,
94
+ includePaths,
95
+ },
96
+ },
97
+ },
98
+ ],
99
+ },
100
+ {
101
+ test: /\.module\.less$/,
102
+ exclude: globalStylePaths,
103
+ use: [
104
+ ...(0, stylesheet_loaders_1.getCommonLoadersForCssModules)(options, includePaths),
105
+ {
106
+ loader: require.resolve('less-loader'),
107
+ options: {
108
+ lessOptions: {
109
+ paths: includePaths,
110
+ },
111
+ },
112
+ },
113
+ ],
114
+ },
115
+ {
116
+ test: /\.module\.styl$/,
117
+ exclude: globalStylePaths,
118
+ use: [
119
+ ...(0, stylesheet_loaders_1.getCommonLoadersForCssModules)(options, includePaths),
120
+ {
121
+ loader: path.join(__dirname, 'webpack/deprecated-stylus-loader.js'),
122
+ options: {
123
+ stylusOptions: {
124
+ include: includePaths,
125
+ },
126
+ },
127
+ },
128
+ ],
129
+ },
130
+ ];
131
+ const globalCssRules = [
132
+ {
133
+ test: /\.css$/,
134
+ exclude: globalStylePaths,
135
+ use: (0, stylesheet_loaders_1.getCommonLoadersForGlobalCss)(options, includePaths),
136
+ },
137
+ {
138
+ test: /\.scss$|\.sass$/,
139
+ exclude: globalStylePaths,
140
+ use: [
141
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalCss)(options, includePaths),
142
+ {
143
+ loader: require.resolve('sass-loader'),
144
+ options: {
145
+ implementation: require('sass'),
146
+ sourceMap: !!options.sourceMap,
147
+ sassOptions: {
148
+ fiber: false,
149
+ // bootstrap-sass requires a minimum precision of 8
150
+ precision: 8,
151
+ includePaths,
152
+ },
153
+ },
154
+ },
155
+ ],
156
+ },
157
+ {
158
+ test: /\.less$/,
159
+ exclude: globalStylePaths,
160
+ use: [
161
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalCss)(options, includePaths),
162
+ {
163
+ loader: require.resolve('less-loader'),
164
+ options: {
165
+ sourceMap: !!options.sourceMap,
166
+ lessOptions: {
167
+ javascriptEnabled: true,
168
+ ...lessPathOptions,
169
+ },
170
+ },
171
+ },
172
+ ],
173
+ },
174
+ {
175
+ test: /\.styl$/,
176
+ exclude: globalStylePaths,
177
+ use: [
178
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalCss)(options, includePaths),
179
+ {
180
+ loader: path.join(__dirname, 'webpack/deprecated-stylus-loader.js'),
181
+ options: {
182
+ sourceMap: !!options.sourceMap,
183
+ stylusOptions: {
184
+ include: includePaths,
185
+ },
186
+ },
187
+ },
188
+ ],
189
+ },
190
+ ];
191
+ const globalStyleRules = [
192
+ {
193
+ test: /\.css$/,
194
+ include: globalStylePaths,
195
+ use: (0, stylesheet_loaders_1.getCommonLoadersForGlobalStyle)(options, includePaths),
196
+ },
197
+ {
198
+ test: /\.scss$|\.sass$/,
199
+ include: globalStylePaths,
200
+ use: [
201
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalStyle)(options, includePaths),
202
+ {
203
+ loader: require.resolve('sass-loader'),
204
+ options: {
205
+ implementation: require('sass'),
206
+ sourceMap: !!options.sourceMap,
207
+ sassOptions: {
208
+ fiber: false,
209
+ // bootstrap-sass requires a minimum precision of 8
210
+ precision: 8,
211
+ includePaths,
212
+ },
213
+ },
214
+ },
215
+ ],
216
+ },
217
+ {
218
+ test: /\.less$/,
219
+ include: globalStylePaths,
220
+ use: [
221
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalStyle)(options, includePaths),
222
+ {
223
+ loader: require.resolve('less-loader'),
224
+ options: {
225
+ sourceMap: !!options.sourceMap,
226
+ lessOptions: {
227
+ javascriptEnabled: true,
228
+ ...lessPathOptions,
229
+ },
230
+ },
231
+ },
232
+ ],
233
+ },
234
+ {
235
+ test: /\.styl$/,
236
+ include: globalStylePaths,
237
+ use: [
238
+ ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalStyle)(options, includePaths),
239
+ {
240
+ loader: require.resolve('stylus-loader'),
241
+ options: {
242
+ sourceMap: !!options.sourceMap,
243
+ stylusOptions: {
244
+ include: includePaths,
245
+ },
246
+ },
247
+ },
248
+ ],
249
+ },
250
+ ];
251
+ const rules = [
252
+ {
253
+ test: /\.css$|\.scss$|\.sass$|\.less$|\.styl$/,
254
+ oneOf: [...cssModuleRules, ...globalCssRules, ...globalStyleRules],
255
+ },
256
+ ];
257
+ plugins.push(
258
+ // extract global css from js files into own css file
259
+ new MiniCssExtractPlugin({
260
+ filename: `[name]${hashFormat.extract}.css`,
261
+ }));
262
+ config.output = {
263
+ ...config.output,
264
+ crossOriginLoading: options.subresourceIntegrity
265
+ ? 'anonymous'
266
+ : false,
267
+ };
268
+ // In case users customize their webpack config with unsupported entry.
269
+ if (typeof config.entry === 'function')
270
+ throw new Error('Entry function is not supported. Use an object.');
271
+ if (typeof config.entry === 'string')
272
+ throw new Error('Entry string is not supported. Use an object.');
273
+ if (Array.isArray(config.entry))
274
+ throw new Error('Entry array is not supported. Use an object.');
275
+ config.entry = { ...config.entry, ...entry };
276
+ config.optimization = {
277
+ ...config.optimization,
278
+ minimizer: [...config.optimization.minimizer, ...minimizer],
279
+ emitOnErrors: false,
280
+ moduleIds: 'deterministic',
281
+ runtimeChunk: options.runtimeChunk ? { name: 'runtime' } : false,
282
+ splitChunks: {
283
+ defaultSizeTypes: config.optimization.splitChunks !== false
284
+ ? config.optimization.splitChunks?.defaultSizeTypes
285
+ : ['...'],
286
+ maxAsyncRequests: Infinity,
287
+ cacheGroups: {
288
+ default: !!options.commonChunk && {
289
+ chunks: 'async',
290
+ minChunks: 2,
291
+ priority: 10,
292
+ },
293
+ common: !!options.commonChunk && {
294
+ name: 'common',
295
+ chunks: 'async',
296
+ minChunks: 2,
297
+ enforce: true,
298
+ priority: 5,
299
+ },
300
+ vendors: false,
301
+ vendor: !!options.vendorChunk && {
302
+ name: 'vendor',
303
+ chunks: (chunk) => chunk.name === 'main',
304
+ enforce: true,
305
+ test: /[\\/]node_modules[\\/]/,
306
+ },
307
+ },
308
+ },
309
+ };
310
+ config.resolve.mainFields = ['browser', 'module', 'main'];
311
+ config.module = {
312
+ ...config.module,
313
+ rules: [
314
+ ...(config.module.rules ?? []),
315
+ // Images: Inline small images, and emit a separate file otherwise.
316
+ {
317
+ test: /\.(avif|bmp|gif|ico|jpe?g|png|webp)$/,
318
+ type: 'asset',
319
+ parser: {
320
+ dataUrlCondition: {
321
+ maxSize: 10000, // 10 kB
322
+ },
323
+ },
324
+ generator: {
325
+ filename: `[name]${hashFormat.file}[ext]`,
326
+ },
327
+ },
328
+ // SVG: same as image but we need to separate it so it can be swapped for SVGR in the React plugin.
329
+ {
330
+ test: /\.svg$/,
331
+ type: 'asset',
332
+ parser: {
333
+ dataUrlCondition: {
334
+ maxSize: 10000, // 10 kB
335
+ },
336
+ },
337
+ generator: {
338
+ filename: `[name]${hashFormat.file}[ext]`,
339
+ },
340
+ },
341
+ // Fonts: Emit separate file and export the URL.
342
+ {
343
+ test: /\.(eot|otf|ttf|woff|woff2)$/,
344
+ type: 'asset/resource',
345
+ generator: {
346
+ filename: `[name]${hashFormat.file}[ext]`,
347
+ },
348
+ },
349
+ ...rules,
350
+ ],
351
+ };
352
+ config.plugins ??= [];
353
+ config.plugins.push(...plugins);
354
+ }
355
+ exports.applyWebConfig = applyWebConfig;
@@ -0,0 +1,53 @@
1
+ import { NormalizedNxWebpackPluginOptions } from '../nx-webpack-plugin-options';
2
+ export declare function createLoaderFromCompiler(options: NormalizedNxWebpackPluginOptions): {
3
+ test: RegExp;
4
+ loader: string;
5
+ exclude: RegExp;
6
+ options: {
7
+ cwd: string;
8
+ emitDecoratorMetadata: boolean;
9
+ isModern: boolean;
10
+ isTest: boolean;
11
+ envName: string;
12
+ cacheDirectory: boolean;
13
+ cacheCompression: boolean;
14
+ };
15
+ } | {
16
+ test: RegExp;
17
+ loader: string;
18
+ exclude: RegExp;
19
+ options: {
20
+ jsc: {
21
+ parser: {
22
+ syntax: string;
23
+ decorators: boolean;
24
+ tsx: boolean;
25
+ };
26
+ transform: {
27
+ react: {
28
+ runtime: string;
29
+ };
30
+ };
31
+ loose: boolean;
32
+ };
33
+ configFile?: undefined;
34
+ transpileOnly?: undefined;
35
+ experimentalWatchApi?: undefined;
36
+ getCustomTransformers?: undefined;
37
+ };
38
+ } | {
39
+ test: RegExp;
40
+ loader: string;
41
+ exclude: RegExp;
42
+ options: {
43
+ configFile: string;
44
+ transpileOnly: boolean;
45
+ experimentalWatchApi: boolean;
46
+ getCustomTransformers: (program: any) => {
47
+ before: any;
48
+ after: any;
49
+ afterDeclarations: any;
50
+ };
51
+ jsc?: undefined;
52
+ };
53
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLoaderFromCompiler = void 0;
4
+ const path = require("path");
5
+ const js_1 = require("@nx/js");
6
+ function createLoaderFromCompiler(options) {
7
+ switch (options.compiler) {
8
+ case 'swc':
9
+ return {
10
+ test: /\.([jt])sx?$/,
11
+ loader: require.resolve('swc-loader'),
12
+ exclude: /node_modules/,
13
+ options: {
14
+ jsc: {
15
+ parser: {
16
+ syntax: 'typescript',
17
+ decorators: true,
18
+ tsx: true,
19
+ },
20
+ transform: {
21
+ react: {
22
+ runtime: 'automatic',
23
+ },
24
+ },
25
+ loose: true,
26
+ },
27
+ },
28
+ };
29
+ case 'tsc':
30
+ const { loadTsTransformers } = require('@nx/js');
31
+ const { compilerPluginHooks, hasPlugin } = loadTsTransformers(options.transformers);
32
+ return {
33
+ test: /\.([jt])sx?$/,
34
+ loader: require.resolve(`ts-loader`),
35
+ exclude: /node_modules/,
36
+ options: {
37
+ configFile: options.tsConfig,
38
+ transpileOnly: !hasPlugin,
39
+ // https://github.com/TypeStrong/ts-loader/pull/685
40
+ experimentalWatchApi: true,
41
+ getCustomTransformers: (program) => ({
42
+ before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)),
43
+ after: compilerPluginHooks.afterHooks.map((hook) => hook(program)),
44
+ afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)),
45
+ }),
46
+ },
47
+ };
48
+ case 'babel':
49
+ const tsConfig = (0, js_1.readTsConfig)(options.tsConfig);
50
+ const babelConfig = {
51
+ test: /\.([jt])sx?$/,
52
+ loader: path.join(__dirname, '../../../utils/web-babel-loader'),
53
+ exclude: /node_modules/,
54
+ options: {
55
+ cwd: path.join(options.root, options.sourceRoot),
56
+ emitDecoratorMetadata: tsConfig.options.emitDecoratorMetadata,
57
+ isModern: true,
58
+ isTest: process.env.NX_CYPRESS_COMPONENT_TEST === 'true',
59
+ envName: process.env.BABEL_ENV ?? process.env.NODE_ENV,
60
+ cacheDirectory: true,
61
+ cacheCompression: false,
62
+ },
63
+ };
64
+ if (options.babelUpwardRootMode) {
65
+ babelConfig.options['rootMode'] = 'upward';
66
+ babelConfig.options['babelrc'] = true;
67
+ }
68
+ else {
69
+ babelConfig.options['configFile'] = options.babelConfig
70
+ ? path.join(options.root, options.babelConfig)
71
+ : path.join(options.root, options.projectRoot, '.babelrc');
72
+ }
73
+ return babelConfig;
74
+ default:
75
+ return null;
76
+ }
77
+ }
78
+ exports.createLoaderFromCompiler = createLoaderFromCompiler;
@@ -0,0 +1 @@
1
+ export declare function getTerserEcmaVersion(projectRoot: string): 2020 | 5;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTerserEcmaVersion = void 0;
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ const browserslist = require("browserslist");
7
+ const VALID_BROWSERSLIST_FILES = ['.browserslistrc', 'browserslist'];
8
+ const ES5_BROWSERS = [
9
+ 'ie 10',
10
+ 'ie 11',
11
+ 'safari 11',
12
+ 'safari 11.1',
13
+ 'safari 12',
14
+ 'safari 12.1',
15
+ 'safari 13',
16
+ 'ios_saf 13.0',
17
+ 'ios_saf 13.3',
18
+ ];
19
+ function getTerserEcmaVersion(projectRoot) {
20
+ let pathToBrowserslistFile = '';
21
+ for (const browserslistFile of VALID_BROWSERSLIST_FILES) {
22
+ const fullPathToFile = path.join(projectRoot, browserslistFile);
23
+ if (fs.existsSync(fullPathToFile)) {
24
+ pathToBrowserslistFile = fullPathToFile;
25
+ break;
26
+ }
27
+ }
28
+ if (!pathToBrowserslistFile) {
29
+ return 2020;
30
+ }
31
+ const env = browserslist.loadConfig({ path: pathToBrowserslistFile });
32
+ const browsers = browserslist(env);
33
+ return browsers.some((b) => ES5_BROWSERS.includes(b)) ? 5 : 2020;
34
+ }
35
+ exports.getTerserEcmaVersion = getTerserEcmaVersion;
@@ -0,0 +1,3 @@
1
+ import { WebpackPluginInstance } from 'webpack';
2
+ import { NormalizedNxWebpackPluginOptions } from '../nx-webpack-plugin-options';
3
+ export declare function instantiateScriptPlugins(options: NormalizedNxWebpackPluginOptions): WebpackPluginInstance[];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.instantiateScriptPlugins = void 0;
4
+ const path = require("path");
5
+ const hash_format_1 = require("../../../utils/hash-format");
6
+ const scripts_webpack_plugin_1 = require("../../../utils/webpack/plugins/scripts-webpack-plugin");
7
+ const normalize_entry_1 = require("../../../utils/webpack/normalize-entry");
8
+ function instantiateScriptPlugins(options) {
9
+ // process global scripts
10
+ const globalScriptsByBundleName = (0, normalize_entry_1.normalizeExtraEntryPoints)(options.scripts || [], 'scripts').reduce((prev, curr) => {
11
+ const bundleName = curr.bundleName;
12
+ const resolvedPath = path.resolve(options.root, curr.input);
13
+ const existingEntry = prev.find((el) => el.bundleName === bundleName);
14
+ if (existingEntry) {
15
+ existingEntry.paths.push(resolvedPath);
16
+ }
17
+ else {
18
+ prev.push({
19
+ inject: curr.inject,
20
+ bundleName,
21
+ paths: [resolvedPath],
22
+ });
23
+ }
24
+ return prev;
25
+ }, []);
26
+ const hashFormat = (0, hash_format_1.getOutputHashFormat)(options.outputHashing);
27
+ const plugins = [];
28
+ // Add a new asset for each entry.
29
+ globalScriptsByBundleName.forEach((script) => {
30
+ const hash = script.inject ? hashFormat.script : '';
31
+ const bundleName = script.bundleName;
32
+ plugins.push(new scripts_webpack_plugin_1.ScriptsWebpackPlugin({
33
+ name: bundleName,
34
+ sourceMap: !!options.sourceMap,
35
+ filename: `${path.basename(bundleName)}${hash}.js`,
36
+ scripts: script.paths,
37
+ basePath: options.sourceRoot,
38
+ }));
39
+ });
40
+ return plugins;
41
+ }
42
+ exports.instantiateScriptPlugins = instantiateScriptPlugins;
@@ -0,0 +1,3 @@
1
+ import { AssetGlobPattern, NormalizedNxWebpackPluginOptions, NxWebpackPluginOptions } from '../nx-webpack-plugin-options';
2
+ export declare function normalizeOptions(options: NxWebpackPluginOptions): NormalizedNxWebpackPluginOptions;
3
+ export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string): AssetGlobPattern[];