@nativescript/webpack 4.0.1 → 4.1.0

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.
@@ -1,368 +1,357 @@
1
- const { join, relative, resolve, sep } = require("path");
1
+ const { join, relative, resolve, sep } = require('path');
2
2
 
3
- const webpack = require("webpack");
4
- const { CleanWebpackPlugin } = require("clean-webpack-plugin");
5
- const CopyWebpackPlugin = require("copy-webpack-plugin");
6
- const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
7
- const TerserPlugin = require("terser-webpack-plugin");
3
+ const webpack = require('webpack');
4
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
6
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
+ const TerserPlugin = require('terser-webpack-plugin');
8
8
 
9
9
  const VueLoaderPlugin = require('vue-loader/lib/plugin');
10
- const NsVueTemplateCompiler = require("nativescript-vue-template-compiler");
10
+ const NsVueTemplateCompiler = require('nativescript-vue-template-compiler');
11
11
 
12
- const nsWebpack = require("@nativescript/webpack");
13
- const nativescriptTarget = require("@nativescript/webpack/nativescript-target");
14
- const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
12
+ const nsWebpack = require('@nativescript/webpack');
13
+ const nativescriptTarget = require('@nativescript/webpack/nativescript-target');
14
+ const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
15
15
  const hashSalt = Date.now().toString();
16
16
 
17
- module.exports = env => {
18
- // Add your custom Activities, Services and other android app components here.
19
- const appComponents = env.appComponents || [];
20
- appComponents.push(...[
21
- "@nativescript/core/ui/frame",
22
- "@nativescript/core/ui/frame/activity",
23
- ]);
17
+ module.exports = (env) => {
18
+ const platform = env && ((env.android && 'android') || (env.ios && 'ios') || env.platform);
19
+ if (!platform) {
20
+ throw new Error('You need to provide a target platform!');
21
+ }
24
22
 
25
- const platform = env && (env.android && "android" || env.ios && "ios" || env.platform);
26
- if (!platform) {
27
- throw new Error("You need to provide a target platform!");
28
- }
23
+ const platforms = ['ios', 'android'];
24
+ const projectRoot = __dirname;
29
25
 
30
- const platforms = ["ios", "android"];
31
- const projectRoot = __dirname;
26
+ if (env.platform) {
27
+ platforms.push(env.platform);
28
+ }
32
29
 
33
- if (env.platform) {
34
- platforms.push(env.platform);
35
- }
30
+ // Default destination inside platforms/<platform>/...
31
+ const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
36
32
 
37
- // Default destination inside platforms/<platform>/...
38
- const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
33
+ const {
34
+ // The 'appPath' and 'appResourcesPath' values are fetched from
35
+ // the nsconfig.json configuration file.
36
+ appPath = 'app',
37
+ appResourcesPath = 'app/App_Resources',
39
38
 
40
- const {
41
- // The 'appPath' and 'appResourcesPath' values are fetched from
42
- // the nsconfig.json configuration file.
43
- appPath = "app",
44
- appResourcesPath = "app/App_Resources",
39
+ // You can provide the following flags when running 'tns run android|ios'
40
+ snapshot, // --env.snapshot
41
+ production, // --env.production
42
+ report, // --env.report
43
+ hmr, // --env.hmr
44
+ sourceMap, // --env.sourceMap
45
+ hiddenSourceMap, // --env.hiddenSourceMap
46
+ unitTesting, // --env.unitTesting
47
+ testing, // --env.testing
48
+ verbose, // --env.verbose
49
+ ci, // --env.ci
50
+ snapshotInDocker, // --env.snapshotInDocker
51
+ skipSnapshotTools, // --env.skipSnapshotTools
52
+ compileSnapshot, // --env.compileSnapshot
53
+ appComponents = [],
54
+ entries = {},
55
+ } = env;
45
56
 
46
- // You can provide the following flags when running 'tns run android|ios'
47
- snapshot, // --env.snapshot
48
- production, // --env.production
49
- report, // --env.report
50
- hmr, // --env.hmr
51
- sourceMap, // --env.sourceMap
52
- hiddenSourceMap, // --env.hiddenSourceMap
53
- unitTesting, // --env.unitTesting
54
- testing, // --env.testing
55
- verbose, // --env.verbose
56
- snapshotInDocker, // --env.snapshotInDocker
57
- skipSnapshotTools, // --env.skipSnapshotTools
58
- compileSnapshot // --env.compileSnapshot
59
- } = env;
57
+ const useLibs = compileSnapshot;
58
+ const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
59
+ const externals = nsWebpack.getConvertedExternals(env.externals);
60
60
 
61
- const useLibs = compileSnapshot;
62
- const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
63
- const externals = nsWebpack.getConvertedExternals(env.externals);
61
+ const mode = production ? 'production' : 'development';
64
62
 
65
- const mode = production ? "production" : "development"
63
+ const appFullPath = resolve(projectRoot, appPath);
64
+ const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
65
+ let coreModulesPackageName = 'tns-core-modules';
66
+ const alias = env.alias || {};
67
+ alias['~/package.json'] = resolve(projectRoot, 'package.json');
68
+ alias['~'] = appFullPath;
69
+ alias['@'] = appFullPath;
70
+ alias['vue'] = 'nativescript-vue';
66
71
 
67
- const appFullPath = resolve(projectRoot, appPath);
68
- const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
69
- let coreModulesPackageName = "tns-core-modules";
70
- const alias = env.alias || {};
71
- alias['~/package.json'] = resolve(projectRoot, 'package.json');
72
- alias['~'] = appFullPath;
73
- alias['@'] = appFullPath;
74
- alias['vue'] = 'nativescript-vue';
72
+ if (hasRootLevelScopedModules) {
73
+ coreModulesPackageName = '@nativescript/core';
74
+ alias['tns-core-modules'] = coreModulesPackageName;
75
+ }
75
76
 
76
- if (hasRootLevelScopedModules) {
77
- coreModulesPackageName = "@nativescript/core";
78
- alias["tns-core-modules"] = coreModulesPackageName;
79
- }
77
+ const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
80
78
 
81
- const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
79
+ const copyIgnore = { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] };
82
80
 
83
- const copyIgnore = { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] };
81
+ const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
82
+ const entryPath = `.${sep}${entryModule}`;
83
+ Object.assign(entries, { bundle: entryPath }, entries);
84
84
 
85
- const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
86
- const entryPath = `.${sep}${entryModule}`;
87
- const entries = env.entries || {};
88
- entries.bundle = entryPath;
85
+ const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some((e) => e.indexOf('@nativescript') > -1);
86
+ if (platform === 'ios' && !areCoreModulesExternal && !testing) {
87
+ entries['tns_modules/inspector_modules'] = '@nativescript/core/inspector_modules';
88
+ }
89
+ console.log(`Bundling application for entryPath ${entryPath}...`);
89
90
 
90
- const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("@nativescript") > -1);
91
- if (platform === "ios" && !areCoreModulesExternal && !testing) {
92
- entries["tns_modules/@nativescript/core/inspector_modules"] = "inspector_modules";
93
- };
94
- console.log(`Bundling application for entryPath ${entryPath}...`);
91
+ let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
95
92
 
96
- let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
93
+ const itemsToClean = [`${dist}/**/*`];
94
+ if (platform === 'android') {
95
+ itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'assets', 'snapshots')}`);
96
+ itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'build', 'configurations', 'nativescript-android-snapshot')}`);
97
+ }
97
98
 
98
- const itemsToClean = [`${dist}/**/*`];
99
- if (platform === "android") {
100
- itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
101
- itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
102
- }
99
+ // Add your custom Activities, Services and other android app components here.
100
+ appComponents.push('@nativescript/core/ui/frame', '@nativescript/core/ui/frame/activity');
103
101
 
104
- nsWebpack.processAppComponents(appComponents, platform);
105
- const config = {
106
- mode: mode,
107
- context: appFullPath,
108
- externals,
109
- watchOptions: {
110
- ignored: [
111
- appResourcesFullPath,
112
- // Don't watch hidden files
113
- "**/.*",
114
- ],
115
- },
116
- target: nativescriptTarget,
117
- // target: nativeScriptVueTarget,
118
- entry: entries,
119
- output: {
120
- pathinfo: false,
121
- path: dist,
122
- sourceMapFilename,
123
- libraryTarget: "commonjs2",
124
- filename: "[name].js",
125
- globalObject: "global",
126
- hashSalt
127
- },
128
- resolve: {
129
- extensions: [".vue", ".ts", ".js", ".scss", ".css"],
130
- // Resolve {N} system modules from @nativescript/core
131
- modules: [
132
- resolve(__dirname, `node_modules/${coreModulesPackageName}`),
133
- resolve(__dirname, "node_modules"),
134
- `node_modules/${coreModulesPackageName}`,
135
- "node_modules",
136
- ],
137
- alias,
138
- // resolve symlinks to symlinked modules
139
- symlinks: true,
140
- },
141
- resolveLoader: {
142
- // don't resolve symlinks to symlinked loaders
143
- symlinks: false,
144
- },
145
- node: {
146
- // Disable node shims that conflict with NativeScript
147
- "http": false,
148
- "timers": false,
149
- "setImmediate": false,
150
- "fs": "empty",
151
- "__dirname": false,
152
- },
153
- devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
154
- optimization: {
155
- runtimeChunk: "single",
156
- noEmitOnErrors: true,
157
- splitChunks: {
158
- cacheGroups: {
159
- vendor: {
160
- name: "vendor",
161
- chunks: "all",
162
- test: (module) => {
163
- const moduleName = module.nameForCondition ? module.nameForCondition() : '';
164
- return /[\\/]node_modules[\\/]/.test(moduleName) ||
165
- appComponents.some(comp => comp === moduleName);
102
+ nsWebpack.processAppComponents(appComponents, platform);
103
+ const config = {
104
+ mode: mode,
105
+ context: appFullPath,
106
+ externals,
107
+ watchOptions: {
108
+ ignored: [
109
+ appResourcesFullPath,
110
+ // Don't watch hidden files
111
+ '**/.*',
112
+ ],
113
+ },
114
+ target: nativescriptTarget,
115
+ // target: nativeScriptVueTarget,
116
+ entry: entries,
117
+ output: {
118
+ pathinfo: false,
119
+ path: dist,
120
+ sourceMapFilename,
121
+ libraryTarget: 'commonjs2',
122
+ filename: '[name].js',
123
+ globalObject: 'global',
124
+ hashSalt,
125
+ },
126
+ resolve: {
127
+ extensions: ['.vue', '.ts', '.js', '.scss', '.css'],
128
+ // Resolve {N} system modules from @nativescript/core
129
+ modules: [resolve(__dirname, `node_modules/${coreModulesPackageName}`), resolve(__dirname, 'node_modules'), `node_modules/${coreModulesPackageName}`, 'node_modules'],
130
+ alias,
131
+ // resolve symlinks to symlinked modules
132
+ symlinks: true,
133
+ },
134
+ resolveLoader: {
135
+ // don't resolve symlinks to symlinked loaders
136
+ symlinks: false,
137
+ },
138
+ node: {
139
+ // Disable node shims that conflict with NativeScript
140
+ http: false,
141
+ timers: false,
142
+ setImmediate: false,
143
+ fs: 'empty',
144
+ __dirname: false,
145
+ },
146
+ devtool: hiddenSourceMap ? 'hidden-source-map' : sourceMap ? 'inline-source-map' : 'none',
147
+ optimization: {
148
+ runtimeChunk: 'single',
149
+ noEmitOnErrors: true,
150
+ splitChunks: {
151
+ cacheGroups: {
152
+ vendor: {
153
+ name: 'vendor',
154
+ chunks: 'all',
155
+ test: (module) => {
156
+ const moduleName = module.nameForCondition ? module.nameForCondition() : '';
157
+ return /[\\/]node_modules[\\/]/.test(moduleName) || appComponents.some((comp) => comp === moduleName);
158
+ },
159
+ enforce: true,
160
+ },
161
+ },
162
+ },
163
+ minimize: Boolean(production),
164
+ minimizer: [
165
+ new TerserPlugin({
166
+ parallel: true,
167
+ cache: !ci,
168
+ sourceMap: isAnySourceMapEnabled,
169
+ terserOptions: {
170
+ output: {
171
+ comments: false,
172
+ semicolons: !isAnySourceMapEnabled,
173
+ },
174
+ compress: {
175
+ // The Android SBG has problems parsing the output
176
+ // when these options are enabled
177
+ collapse_vars: platform !== 'android',
178
+ sequences: platform !== 'android',
179
+ // For v8 Compatibility
180
+ keep_infinity: true, // for V8
181
+ reduce_funcs: false, // for V8
182
+ // custom
183
+ drop_console: production,
184
+ drop_debugger: true,
185
+ global_defs: {
186
+ __UGLIFIED__: true,
187
+ },
188
+ },
189
+ keep_fnames: true,
190
+ // Required for Element Level CSS, Observable Events, & Android Frame
191
+ keep_classnames: true,
192
+ },
193
+ }),
194
+ ],
195
+ },
196
+ module: {
197
+ rules: [
198
+ {
199
+ include: [join(appFullPath, entryPath + '.js'), join(appFullPath, entryPath + '.ts')],
200
+ use: [
201
+ // Require all Android app components
202
+ platform === 'android' && {
203
+ loader: '@nativescript/webpack/helpers/android-app-components-loader',
204
+ options: { modules: appComponents },
205
+ },
166
206
 
167
- },
168
- enforce: true,
169
- },
170
- },
171
- },
172
- minimize: Boolean(production),
173
- minimizer: [
174
- new TerserPlugin({
175
- parallel: true,
176
- cache: true,
177
- sourceMap: isAnySourceMapEnabled,
178
- terserOptions: {
179
- output: {
180
- comments: false,
181
- semicolons: !isAnySourceMapEnabled
182
- },
183
- compress: {
184
- // The Android SBG has problems parsing the output
185
- // when these options are enabled
186
- 'collapse_vars': platform !== "android",
187
- sequences: platform !== "android",
188
- },
189
- keep_fnames: true,
190
- },
191
- }),
192
- ],
193
- },
194
- module: {
195
- rules: [{
196
- include: [join(appFullPath, entryPath + ".js"), join(appFullPath, entryPath + ".ts")],
197
- use: [
198
- // Require all Android app components
199
- platform === "android" && {
200
- loader: "@nativescript/webpack/helpers/android-app-components-loader",
201
- options: { modules: appComponents },
202
- },
207
+ {
208
+ loader: '@nativescript/webpack/bundle-config-loader',
209
+ options: {
210
+ registerPages: true, // applicable only for non-angular apps
211
+ loadCss: !snapshot, // load the application css if in debug mode
212
+ unitTesting,
213
+ appFullPath,
214
+ projectRoot,
215
+ ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform),
216
+ },
217
+ },
218
+ ].filter((loader) => Boolean(loader)),
219
+ },
220
+ {
221
+ test: /[\/|\\]app\.css$/,
222
+ use: [
223
+ '@nativescript/webpack/helpers/style-hot-loader',
224
+ {
225
+ loader: '@nativescript/webpack/helpers/css2json-loader',
226
+ options: { useForImports: true },
227
+ },
228
+ ],
229
+ },
230
+ {
231
+ test: /[\/|\\]app\.scss$/,
232
+ use: [
233
+ '@nativescript/webpack/helpers/style-hot-loader',
234
+ {
235
+ loader: '@nativescript/webpack/helpers/css2json-loader',
236
+ options: { useForImports: true },
237
+ },
238
+ 'sass-loader',
239
+ ],
240
+ },
241
+ {
242
+ test: /\.css$/,
243
+ exclude: /[\/|\\]app\.css$/,
244
+ use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }],
245
+ },
246
+ {
247
+ test: /\.scss$/,
248
+ exclude: /[\/|\\]app\.scss$/,
249
+ use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }, 'sass-loader'],
250
+ },
251
+ {
252
+ test: /\.js$/,
253
+ loader: 'babel-loader',
254
+ },
255
+ {
256
+ test: /\.ts$/,
257
+ loader: 'ts-loader',
258
+ options: {
259
+ appendTsSuffixTo: [/\.vue$/],
260
+ allowTsInNodeModules: true,
261
+ compilerOptions: {
262
+ declaration: false,
263
+ },
264
+ getCustomTransformers: (program) => ({
265
+ before: [require('@nativescript/webpack/transformers/ns-transform-native-classes').default],
266
+ }),
267
+ },
268
+ },
269
+ {
270
+ test: /\.vue$/,
271
+ loader: 'vue-loader',
272
+ options: {
273
+ compiler: NsVueTemplateCompiler,
274
+ },
275
+ },
276
+ ],
277
+ },
278
+ plugins: [
279
+ // ... Vue Loader plugin omitted
280
+ // make sure to include the plugin!
281
+ new VueLoaderPlugin(),
282
+ // Define useful constants like TNS_WEBPACK
283
+ new webpack.DefinePlugin({
284
+ 'global.TNS_WEBPACK': 'true',
285
+ 'global.isAndroid': platform === 'android',
286
+ 'global.isIOS': platform === 'ios',
287
+ TNS_ENV: JSON.stringify(mode),
288
+ process: 'global.process',
289
+ }),
290
+ // Remove all files from the out dir.
291
+ new CleanWebpackPlugin({
292
+ cleanOnceBeforeBuildPatterns: itemsToClean,
293
+ verbose: !!verbose,
294
+ }),
295
+ // Copy assets
296
+ new CopyWebpackPlugin([{ from: { glob: 'assets/**', dot: false } }, { from: { glob: 'fonts/**', dot: false } }, { from: { glob: '**/*.jpg', dot: false } }, { from: { glob: '**/*.png', dot: false } }], copyIgnore),
297
+ new nsWebpack.GenerateNativeScriptEntryPointsPlugin('bundle'),
298
+ // For instructions on how to set up workers with webpack
299
+ // check out https://github.com/nativescript/worker-loader
300
+ new NativeScriptWorkerPlugin(),
301
+ new nsWebpack.PlatformFSPlugin({
302
+ platform,
303
+ platforms,
304
+ }),
305
+ // Does IPC communication with the {N} CLI to notify events when running in watch mode.
306
+ new nsWebpack.WatchStateLoggerPlugin(),
307
+ ],
308
+ };
203
309
 
204
- {
205
- loader: "@nativescript/webpack/bundle-config-loader",
206
- options: {
207
- registerPages: true, // applicable only for non-angular apps
208
- loadCss: !snapshot, // load the application css if in debug mode
209
- unitTesting,
210
- appFullPath,
211
- projectRoot,
212
- ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
213
- },
214
- },
215
- ].filter(loader => Boolean(loader)),
216
- },
217
- {
218
- test: /[\/|\\]app\.css$/,
219
- use: [
220
- '@nativescript/webpack/helpers/style-hot-loader',
221
- {
222
- loader: "@nativescript/webpack/helpers/css2json-loader",
223
- options: { useForImports: true }
224
- },
225
- ],
226
- },
227
- {
228
- test: /[\/|\\]app\.scss$/,
229
- use: [
230
- '@nativescript/webpack/helpers/style-hot-loader',
231
- {
232
- loader: "@nativescript/webpack/helpers/css2json-loader",
233
- options: { useForImports: true }
234
- },
235
- 'sass-loader',
236
- ],
237
- },
238
- {
239
- test: /\.css$/,
240
- exclude: /[\/|\\]app\.css$/,
241
- use: [
242
- '@nativescript/webpack/helpers/style-hot-loader',
243
- '@nativescript/webpack/helpers/apply-css-loader.js',
244
- { loader: "css-loader", options: { url: false } },
245
- ],
246
- },
247
- {
248
- test: /\.scss$/,
249
- exclude: /[\/|\\]app\.scss$/,
250
- use: [
251
- '@nativescript/webpack/helpers/style-hot-loader',
252
- '@nativescript/webpack/helpers/apply-css-loader.js',
253
- { loader: "css-loader", options: { url: false } },
254
- 'sass-loader',
255
- ],
256
- },
257
- {
258
- test: /\.js$/,
259
- loader: 'babel-loader',
260
- },
261
- {
262
- test: /\.ts$/,
263
- loader: 'ts-loader',
264
- options: {
265
- appendTsSuffixTo: [/\.vue$/],
266
- allowTsInNodeModules: true,
267
- compilerOptions: {
268
- declaration: false
269
- },
270
- getCustomTransformers: (program) => ({
271
- before: [
272
- require("@nativescript/webpack/transformers/ns-transform-native-classes").default
273
- ]
274
- })
275
- },
276
- },
277
- {
278
- test: /\.vue$/,
279
- loader: "vue-loader",
280
- options: {
281
- compiler: NsVueTemplateCompiler,
282
- },
283
- },
284
- ],
285
- },
286
- plugins: [
287
- // ... Vue Loader plugin omitted
288
- // make sure to include the plugin!
289
- new VueLoaderPlugin(),
290
- // Define useful constants like TNS_WEBPACK
291
- new webpack.DefinePlugin({
292
- "global.TNS_WEBPACK": "true",
293
- "global.isAndroid": platform === 'android',
294
- "global.isIOS": platform === 'ios',
295
- "TNS_ENV": JSON.stringify(mode),
296
- "process": "global.process"
297
- }),
298
- // Remove all files from the out dir.
299
- new CleanWebpackPlugin({
300
- cleanOnceBeforeBuildPatterns: itemsToClean,
301
- verbose: !!verbose
302
- }),
303
- // Copy assets
304
- new CopyWebpackPlugin([
305
- { from: { glob: 'assets/**', dot: false } },
306
- { from: { glob: 'fonts/**', dot: false } },
307
- { from: { glob: '**/*.jpg', dot: false } },
308
- { from: { glob: '**/*.png', dot: false } },
309
- ], copyIgnore),
310
- new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
311
- // For instructions on how to set up workers with webpack
312
- // check out https://github.com/nativescript/worker-loader
313
- new NativeScriptWorkerPlugin(),
314
- new nsWebpack.PlatformFSPlugin({
315
- platform,
316
- platforms,
317
- }),
318
- // Does IPC communication with the {N} CLI to notify events when running in watch mode.
319
- new nsWebpack.WatchStateLoggerPlugin()
320
- ],
321
- };
310
+ if (unitTesting) {
311
+ config.module.rules.push(
312
+ {
313
+ test: /-page\.js$/,
314
+ use: '@nativescript/webpack/helpers/script-hot-loader',
315
+ },
316
+ {
317
+ test: /\.(html|xml)$/,
318
+ use: '@nativescript/webpack/helpers/markup-hot-loader',
319
+ },
322
320
 
323
- if (unitTesting) {
324
- config.module.rules.push(
325
- {
326
- test: /-page\.js$/,
327
- use: "@nativescript/webpack/helpers/script-hot-loader"
328
- },
329
- {
330
- test: /\.(html|xml)$/,
331
- use: "@nativescript/webpack/helpers/markup-hot-loader"
332
- },
321
+ { test: /\.(html|xml)$/, use: '@nativescript/webpack/helpers/xml-namespace-loader' }
322
+ );
323
+ }
333
324
 
334
- { test: /\.(html|xml)$/, use: "@nativescript/webpack/helpers/xml-namespace-loader" }
335
- );
336
- }
325
+ if (report) {
326
+ // Generate report files for bundles content
327
+ config.plugins.push(
328
+ new BundleAnalyzerPlugin({
329
+ analyzerMode: 'static',
330
+ openAnalyzer: false,
331
+ generateStatsFile: true,
332
+ reportFilename: resolve(projectRoot, 'report', `report.html`),
333
+ statsFilename: resolve(projectRoot, 'report', `stats.json`),
334
+ })
335
+ );
336
+ }
337
337
 
338
- if (report) {
339
- // Generate report files for bundles content
340
- config.plugins.push(new BundleAnalyzerPlugin({
341
- analyzerMode: "static",
342
- openAnalyzer: false,
343
- generateStatsFile: true,
344
- reportFilename: resolve(projectRoot, "report", `report.html`),
345
- statsFilename: resolve(projectRoot, "report", `stats.json`),
346
- }));
347
- }
338
+ if (snapshot) {
339
+ config.plugins.push(
340
+ new nsWebpack.NativeScriptSnapshotPlugin({
341
+ chunk: 'vendor',
342
+ requireModules: ['@nativescript/core/bundle-entry-points'],
343
+ projectRoot,
344
+ webpackConfig: config,
345
+ snapshotInDocker,
346
+ skipSnapshotTools,
347
+ useLibs,
348
+ })
349
+ );
350
+ }
348
351
 
349
- if (snapshot) {
350
- config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
351
- chunk: "vendor",
352
- requireModules: [
353
- "@nativescript/core/bundle-entry-points",
354
- ],
355
- projectRoot,
356
- webpackConfig: config,
357
- snapshotInDocker,
358
- skipSnapshotTools,
359
- useLibs
360
- }));
361
- }
352
+ if (hmr) {
353
+ config.plugins.push(new webpack.HotModuleReplacementPlugin());
354
+ }
362
355
 
363
- if (hmr) {
364
- config.plugins.push(new webpack.HotModuleReplacementPlugin());
365
- }
366
-
367
- return config;
356
+ return config;
368
357
  };