@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.
@@ -2,87 +2,86 @@
2
2
  * @see https://github.com/NativeScript/NativeScript/tree/feat/ns7-finishing-touches/packages/webpack/templates
3
3
  * @see https://github.com/NativeScript/NativeScript/pull/8801/files
4
4
  */
5
- const webpackConfig = require("./webpack.typescript");
6
- const webpack = require("webpack");
5
+ const webpackConfig = require('./webpack.typescript');
6
+ const webpack = require('webpack');
7
7
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
8
8
 
9
9
  module.exports = (env) => {
10
- env = env || {};
11
- const hmr = env.hmr;
12
- const production = env.production;
13
- const isAnySourceMapEnabled = !!env.sourceMap || !!env.hiddenSourceMap;
10
+ env = env || {};
11
+ const hmr = env.hmr;
12
+ const production = env.production;
13
+ const isAnySourceMapEnabled = !!env.sourceMap || !!env.hiddenSourceMap;
14
14
 
15
- const baseConfig = webpackConfig(env);
15
+ const baseConfig = webpackConfig(env);
16
16
 
17
- /** Find the rule for transpiling ts files ("ts-loader"), and modify it to test for .tsx files too. */
18
- const tsxRule = baseConfig.module.rules.find(rule => rule.use && rule.use.loader === "ts-loader");
19
- tsxRule.test = /\.(ts|tsx)$/;
20
- tsxRule.use = [
21
- /**
22
- * Add React Refresh HMR support.
23
- * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/55028c6355b31e697e21bf3e9a48613a7b94bee7/examples/typescript-without-babel/webpack.config.js#L18-L21
24
- */
25
- hmr && !production && {
26
- loader: "babel-loader",
27
- options: {
28
- sourceMaps: isAnySourceMapEnabled ? "inline" : false,
29
- babelrc: false,
30
- plugins: ['react-refresh/babel']
31
- }
32
- },
33
- tsxRule.use,
34
- ].filter(Boolean);
17
+ /** Find the rule for transpiling ts files ("ts-loader"), and modify it to test for .tsx files too. */
18
+ const tsxRule = baseConfig.module.rules.find((rule) => rule.use && rule.use.loader === 'ts-loader');
19
+ tsxRule.test = /\.(ts|tsx)$/;
20
+ tsxRule.use = [
21
+ /**
22
+ * Add React Refresh HMR support.
23
+ * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/55028c6355b31e697e21bf3e9a48613a7b94bee7/examples/typescript-without-babel/webpack.config.js#L18-L21
24
+ */
25
+ hmr &&
26
+ !production && {
27
+ loader: 'babel-loader',
28
+ options: {
29
+ sourceMaps: isAnySourceMapEnabled ? 'inline' : false,
30
+ babelrc: false,
31
+ plugins: ['react-refresh/babel'],
32
+ },
33
+ },
34
+ tsxRule.use,
35
+ ].filter(Boolean);
35
36
 
36
- /**
37
- * Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files
38
- * (and also js files, which it should have been doing to begin with!)
39
- */
40
- const nativeScriptDevWebpackHotLoader = baseConfig.module.rules.find(rule =>
41
- rule.use === "@nativescript/webpack/hmr/hot-loader"
42
- );
43
- nativeScriptDevWebpackHotLoader.test = /\.(ts|tsx|js|css|scss|html|xml)$/;
37
+ /**
38
+ * Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files
39
+ * (and also js files, which it should have been doing to begin with!)
40
+ */
41
+ const nativeScriptDevWebpackHotLoader = baseConfig.module.rules.find((rule) => rule.use === '@nativescript/webpack/hmr/hot-loader');
42
+ nativeScriptDevWebpackHotLoader.test = /\.(ts|tsx|js|css|scss|html|xml)$/;
44
43
 
45
- /** We don't officially support JSX. Makes the webpack config rather more complicated to set up. */
46
- baseConfig.resolve.extensions = [".tsx", ...baseConfig.resolve.extensions];
47
- baseConfig.resolve.alias["react-dom"] = "react-nativescript";
44
+ /** We don't officially support JSX. Makes the webpack config rather more complicated to set up. */
45
+ baseConfig.resolve.extensions = ['.tsx', ...baseConfig.resolve.extensions];
46
+ baseConfig.resolve.alias['react-dom'] = 'react-nativescript';
48
47
 
49
- /** Augment NativeScript's existing DefinePlugin definitions with a few more of our own. */
50
- const existingDefinePlugin = baseConfig.plugins.find(plugin =>
51
- plugin && plugin.constructor && plugin.constructor.name === "DefinePlugin"
52
- );
53
- baseConfig.plugins.splice(
54
- baseConfig.plugins.indexOf(existingDefinePlugin),
55
- 1,
56
- new webpack.DefinePlugin({
57
- ...existingDefinePlugin.definitions,
58
- /** For various libraries in the React ecosystem. */
59
- "__DEV__": production ? "false" : "true",
60
- "__TEST__": "false",
61
- /**
62
- * Primarily for React Fast Refresh plugin, but technically the allowHmrInProduction option could be used instead.
63
- * Worth including anyway, as there are plenty of Node libraries that use this flag.
64
- */
65
- "process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"),
66
- }),
67
- );
48
+ /** Augment NativeScript's existing DefinePlugin definitions with a few more of our own. */
49
+ const existingDefinePlugin = baseConfig.plugins.find((plugin) => plugin && plugin.constructor && plugin.constructor.name === 'DefinePlugin');
50
+ baseConfig.plugins.splice(
51
+ baseConfig.plugins.indexOf(existingDefinePlugin),
52
+ 1,
53
+ new webpack.DefinePlugin({
54
+ ...existingDefinePlugin.definitions,
55
+ /** For various libraries in the React ecosystem. */
56
+ __DEV__: production ? 'false' : 'true',
57
+ __TEST__: 'false',
58
+ /**
59
+ * Primarily for React Fast Refresh plugin, but technically the allowHmrInProduction option could be used instead.
60
+ * Worth including anyway, as there are plenty of Node libraries that use this flag.
61
+ */
62
+ 'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
63
+ })
64
+ );
68
65
 
69
- if(hmr && !production){
70
- baseConfig.plugins.push(new ReactRefreshWebpackPlugin({
71
- /**
72
- * Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
73
- * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
74
- */
75
- overlay: false,
76
- /**
77
- * If you (temporarily) want to enable HMR on a production build:
78
- * 1) Set `forceEnable` to `true`
79
- * 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
80
- */
81
- forceEnable: false,
82
- }));
83
- } else {
84
- baseConfig.plugins = baseConfig.plugins.filter(p => !(p && p.constructor && p.constructor.name === "HotModuleReplacementPlugin"));
85
- }
66
+ if (hmr && !production) {
67
+ baseConfig.plugins.push(
68
+ new ReactRefreshWebpackPlugin({
69
+ /**
70
+ * Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
71
+ * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
72
+ */
73
+ overlay: false,
74
+ /**
75
+ * If you (temporarily) want to enable HMR on a production build:
76
+ * 1) Set `forceEnable` to `true`
77
+ * 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
78
+ */
79
+ forceEnable: false,
80
+ })
81
+ );
82
+ } else {
83
+ baseConfig.plugins = baseConfig.plugins.filter((p) => !(p && p.constructor && p.constructor.name === 'HotModuleReplacementPlugin'));
84
+ }
86
85
 
87
- return baseConfig;
88
- };
86
+ return baseConfig;
87
+ };
@@ -1,34 +1,27 @@
1
- const { join, relative, resolve, sep } = require("path");
1
+ const { join, relative, resolve, sep } = require('path');
2
2
  const fs = require('fs');
3
3
 
4
- const webpack = require("webpack");
5
- const nsWebpack = require("@nativescript/webpack");
6
- const nativescriptTarget = require("@nativescript/webpack/nativescript-target");
7
- const { getNoEmitOnErrorFromTSConfig } = require("@nativescript/webpack/utils/tsconfig-utils");
8
- const { CleanWebpackPlugin } = require("clean-webpack-plugin");
9
- const CopyWebpackPlugin = require("copy-webpack-plugin");
4
+ const webpack = require('webpack');
5
+ const nsWebpack = require('@nativescript/webpack');
6
+ const nativescriptTarget = require('@nativescript/webpack/nativescript-target');
7
+ const { getNoEmitOnErrorFromTSConfig } = require('@nativescript/webpack/utils/tsconfig-utils');
8
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
9
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
10
10
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
11
- const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
12
- const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
13
- const TerserPlugin = require("terser-webpack-plugin");
11
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
12
+ const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
13
+ const TerserPlugin = require('terser-webpack-plugin');
14
14
  const hashSalt = Date.now().toString();
15
- const preprocessConfig = require("./svelte.config.js");
16
- const svelteNativePreprocessor = require("svelte-native-preprocessor");
15
+ const preprocessConfig = require('./svelte.config.js');
16
+ const svelteNativePreprocessor = require('svelte-native-preprocessor');
17
17
 
18
- module.exports = env => {
19
- // Add your custom Activities, Services and other Android app components here.
20
- const appComponents = env.appComponents || [];
21
- appComponents.push(...[
22
- "@nativescript/core/ui/frame",
23
- "@nativescript/core/ui/frame/activity",
24
- ]);
25
-
26
- const platform = env && (env.android && "android" || env.ios && "ios" || env.platform);
18
+ module.exports = (env) => {
19
+ const platform = env && ((env.android && 'android') || (env.ios && 'ios') || env.platform);
27
20
  if (!platform) {
28
- throw new Error("You need to provide a target platform!");
21
+ throw new Error('You need to provide a target platform!');
29
22
  }
30
23
 
31
- const platforms = ["ios", "android"];
24
+ const platforms = ['ios', 'android'];
32
25
  const projectRoot = __dirname;
33
26
 
34
27
  if (env.platform) {
@@ -41,8 +34,8 @@ module.exports = env => {
41
34
  const {
42
35
  // The 'appPath' and 'appResourcesPath' values are fetched from
43
36
  // the nsconfig.json configuration file.
44
- appPath = "src",
45
- appResourcesPath = "App_Resources",
37
+ appPath = 'src',
38
+ appResourcesPath = 'App_Resources',
46
39
 
47
40
  // You can provide the following flags when running 'tns run android|ios'
48
41
  snapshot, // --env.snapshot
@@ -55,9 +48,12 @@ module.exports = env => {
55
48
  unitTesting, // --env.unitTesting,
56
49
  testing, // --env.testing
57
50
  verbose, // --env.verbose
51
+ ci, // --env.ci
58
52
  snapshotInDocker, // --env.snapshotInDocker
59
53
  skipSnapshotTools, // --env.skipSnapshotTools
60
- compileSnapshot // --env.compileSnapshot
54
+ compileSnapshot, // --env.compileSnapshot
55
+ appComponents = [],
56
+ entries = {},
61
57
  } = env;
62
58
 
63
59
  const useLibs = compileSnapshot;
@@ -70,14 +66,14 @@ module.exports = env => {
70
66
  appFullPath = resolve(projectRoot, 'app');
71
67
  }
72
68
  const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
73
- let coreModulesPackageName = "tns-core-modules";
69
+ let coreModulesPackageName = 'tns-core-modules';
74
70
  const alias = env.alias || {};
75
71
  alias['~/package.json'] = resolve(projectRoot, 'package.json');
76
72
  alias['~'] = appFullPath;
77
73
 
78
74
  if (hasRootLevelScopedModules) {
79
- coreModulesPackageName = "@nativescript/core";
80
- alias["tns-core-modules"] = coreModulesPackageName;
75
+ coreModulesPackageName = '@nativescript/core';
76
+ alias['tns-core-modules'] = coreModulesPackageName;
81
77
  }
82
78
  const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
83
79
 
@@ -85,37 +81,39 @@ module.exports = env => {
85
81
 
86
82
  const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
87
83
  const entryPath = `.${sep}${entryModule}.ts`;
88
- const entries = env.entries || {};
89
- entries.bundle = entryPath;
84
+ Object.assign(entries, { bundle: entryPath }, entries);
90
85
 
91
- const tsConfigPath = resolve(projectRoot, "tsconfig.json");
86
+ const tsConfigPath = resolve(projectRoot, 'tsconfig.json');
92
87
 
93
- const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("@nativescript") > -1);
94
- if (platform === "ios" && !areCoreModulesExternal && !testing) {
95
- entries["tns_modules/@nativescript/core/inspector_modules"] = "inspector_modules";
96
- };
88
+ const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some((e) => e.indexOf('@nativescript') > -1);
89
+ if (platform === 'ios' && !areCoreModulesExternal && !testing) {
90
+ entries['tns_modules/inspector_modules'] = '@nativescript/core/inspector_modules';
91
+ }
97
92
 
98
93
  let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
99
94
 
100
95
  const itemsToClean = [`${dist}/**/*`];
101
- if (platform === "android") {
102
- itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
103
- itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
96
+ if (platform === 'android') {
97
+ itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'assets', 'snapshots')}`);
98
+ itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'build', 'configurations', 'nativescript-android-snapshot')}`);
104
99
  }
105
100
 
106
101
  const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath);
107
102
 
103
+ // Add your custom Activities, Services and other android app components here.
104
+ appComponents.push('@nativescript/core/ui/frame', '@nativescript/core/ui/frame/activity');
105
+
108
106
  nsWebpack.processAppComponents(appComponents, platform);
109
107
  const config = {
110
- mode: production ? "production" : "development",
108
+ mode: production ? 'production' : 'development',
111
109
  context: appFullPath,
112
110
  externals,
113
111
  watchOptions: {
114
112
  ignored: [
115
113
  appResourcesFullPath,
116
114
  // Don't watch hidden files
117
- "**/.*",
118
- ]
115
+ '**/.*',
116
+ ],
119
117
  },
120
118
  target: nativescriptTarget,
121
119
  entry: entries,
@@ -123,74 +121,78 @@ module.exports = env => {
123
121
  pathinfo: false,
124
122
  path: dist,
125
123
  sourceMapFilename,
126
- libraryTarget: "commonjs2",
127
- filename: "[name].js",
128
- globalObject: "global",
129
- hashSalt
124
+ libraryTarget: 'commonjs2',
125
+ filename: '[name].js',
126
+ globalObject: 'global',
127
+ hashSalt,
130
128
  },
131
129
  resolve: {
132
- extensions: [".ts", ".mjs", ".js", ".svelte", ".scss", ".css"],
130
+ extensions: ['.ts', '.mjs', '.js', '.svelte', '.scss', '.css'],
133
131
  // Resolve {N} system modules from @nativescript/core
134
- modules: [
135
- resolve(__dirname, `node_modules/${coreModulesPackageName}`),
136
- resolve(__dirname, "node_modules"),
137
- `node_modules/${coreModulesPackageName}`,
138
- "node_modules",
139
- ],
132
+ modules: [resolve(__dirname, `node_modules/${coreModulesPackageName}`), resolve(__dirname, 'node_modules'), `node_modules/${coreModulesPackageName}`, 'node_modules'],
140
133
  alias,
141
134
  // resolve symlinks to symlinked modules
142
- symlinks: true
135
+ symlinks: true,
143
136
  },
144
137
  resolveLoader: {
145
138
  // don't resolve symlinks to symlinked loaders
146
- symlinks: false
139
+ symlinks: false,
147
140
  },
148
141
  node: {
149
142
  // Disable node shims that conflict with NativeScript
150
- "http": false,
151
- "timers": false,
152
- "setImmediate": false,
153
- "fs": "empty",
154
- "__dirname": false,
143
+ http: false,
144
+ timers: false,
145
+ setImmediate: false,
146
+ fs: 'empty',
147
+ __dirname: false,
155
148
  },
156
- devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
149
+ devtool: hiddenSourceMap ? 'hidden-source-map' : sourceMap ? 'inline-source-map' : 'none',
157
150
  optimization: {
158
- runtimeChunk: "single",
151
+ runtimeChunk: 'single',
159
152
  noEmitOnErrors: noEmitOnErrorFromTSConfig,
160
153
  splitChunks: {
161
154
  cacheGroups: {
162
155
  vendor: {
163
- name: "vendor",
164
- chunks: "all",
156
+ name: 'vendor',
157
+ chunks: 'all',
165
158
  test: (module, chunks) => {
166
159
  const moduleName = module.nameForCondition ? module.nameForCondition() : '';
167
- return /[\\/]node_modules[\\/]/.test(moduleName) ||
168
- appComponents.some(comp => comp === moduleName);
169
-
160
+ return /[\\/]node_modules[\\/]/.test(moduleName) || appComponents.some((comp) => comp === moduleName);
170
161
  },
171
162
  enforce: true,
172
163
  },
173
- }
164
+ },
174
165
  },
175
166
  minimize: !!uglify,
176
167
  minimizer: [
177
168
  new TerserPlugin({
178
169
  parallel: true,
179
- cache: true,
170
+ cache: !ci,
180
171
  sourceMap: isAnySourceMapEnabled,
181
172
  terserOptions: {
182
173
  output: {
183
174
  comments: false,
184
- semicolons: !isAnySourceMapEnabled
175
+ semicolons: !isAnySourceMapEnabled,
185
176
  },
186
177
  compress: {
187
178
  // The Android SBG has problems parsing the output
188
179
  // when these options are enabled
189
- 'collapse_vars': platform !== "android",
190
- sequences: platform !== "android",
191
- }
192
- }
193
- })
180
+ collapse_vars: platform !== 'android',
181
+ sequences: platform !== 'android',
182
+ // For v8 Compatibility
183
+ keep_infinity: true, // for V8
184
+ reduce_funcs: false, // for V8
185
+ // custom
186
+ drop_console: production,
187
+ drop_debugger: true,
188
+ global_defs: {
189
+ __UGLIFIED__: true,
190
+ },
191
+ },
192
+ // Required for Element Level CSS, Observable Events, & Android Frame
193
+ keep_classnames: true,
194
+ },
195
+ }),
194
196
  ],
195
197
  },
196
198
  module: {
@@ -199,42 +201,39 @@ module.exports = env => {
199
201
  include: join(appFullPath, entryPath),
200
202
  use: [
201
203
  // Require all Android app components
202
- platform === "android" && {
203
- loader: "@nativescript/webpack/helpers/android-app-components-loader",
204
- options: { modules: appComponents }
204
+ platform === 'android' && {
205
+ loader: '@nativescript/webpack/helpers/android-app-components-loader',
206
+ options: { modules: appComponents },
205
207
  },
206
208
 
207
209
  {
208
- loader: "@nativescript/webpack/bundle-config-loader",
210
+ loader: '@nativescript/webpack/bundle-config-loader',
209
211
  options: {
210
212
  loadCss: !snapshot, // load the application css if in debug mode
211
213
  unitTesting,
212
214
  appFullPath,
213
215
  projectRoot,
214
- ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
215
- }
216
+ ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform),
217
+ },
216
218
  },
217
- ].filter(loader => !!loader)
219
+ ].filter((loader) => !!loader),
218
220
  },
219
221
 
220
222
  {
221
223
  test: /\.(ts|css|scss|html|xml)$/,
222
- use: "@nativescript/webpack/hmr/hot-loader"
224
+ use: '@nativescript/webpack/hmr/hot-loader',
223
225
  },
224
226
 
225
- { test: /\.(html|xml)$/, use: "@nativescript/webpack/helpers/xml-namespace-loader" },
227
+ { test: /\.(html|xml)$/, use: '@nativescript/webpack/helpers/xml-namespace-loader' },
226
228
 
227
229
  {
228
230
  test: /\.css$/,
229
- use: "@nativescript/webpack/helpers/css2json-loader"
231
+ use: '@nativescript/webpack/helpers/css2json-loader',
230
232
  },
231
233
 
232
234
  {
233
235
  test: /\.scss$/,
234
- use: [
235
- "@nativescript/webpack/helpers/css2json-loader",
236
- "sass-loader"
237
- ]
236
+ use: ['@nativescript/webpack/helpers/css2json-loader', 'sass-loader'],
238
237
  },
239
238
 
240
239
  {
@@ -244,7 +243,7 @@ module.exports = env => {
244
243
  {
245
244
  test: /\.ts$/,
246
245
  use: {
247
- loader: "ts-loader",
246
+ loader: 'ts-loader',
248
247
  options: {
249
248
  configFile: tsConfigPath,
250
249
  // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
@@ -253,15 +252,13 @@ module.exports = env => {
253
252
  allowTsInNodeModules: true,
254
253
  compilerOptions: {
255
254
  sourceMap: isAnySourceMapEnabled,
256
- declaration: false
255
+ declaration: false,
257
256
  },
258
257
  getCustomTransformers: (program) => ({
259
- before: [
260
- require("@nativescript/webpack/transformers/ns-transform-native-classes").default
261
- ]
262
- })
258
+ before: [require('@nativescript/webpack/transformers/ns-transform-native-classes').default],
259
+ }),
263
260
  },
264
- }
261
+ },
265
262
  },
266
263
  {
267
264
  test: /\.svelte$/,
@@ -275,35 +272,30 @@ module.exports = env => {
275
272
  hotReload: env.production ? false : true,
276
273
  hotOptions: {
277
274
  injectCss: false,
278
- native: true
279
- }
280
- }
281
- }
282
- ]
283
- }
284
- ]
275
+ native: true,
276
+ },
277
+ },
278
+ },
279
+ ],
280
+ },
281
+ ],
285
282
  },
286
283
  plugins: [
287
284
  // Define useful constants like TNS_WEBPACK
288
285
  new webpack.DefinePlugin({
289
- "global.TNS_WEBPACK": "true",
290
- "global.isAndroid": platform === 'android',
291
- "global.isIOS": platform === 'ios',
292
- "process": "global.process",
286
+ 'global.TNS_WEBPACK': 'true',
287
+ 'global.isAndroid': platform === 'android',
288
+ 'global.isIOS': platform === 'ios',
289
+ process: 'global.process',
293
290
  }),
294
291
  // Remove all files from the out dir.
295
292
  new CleanWebpackPlugin({
296
293
  cleanOnceBeforeBuildPatterns: itemsToClean,
297
- verbose: !!verbose
294
+ verbose: !!verbose,
298
295
  }),
299
296
  // Copy assets
300
- new CopyWebpackPlugin([
301
- { from: { glob: 'assets/**', dot: false } },
302
- { from: { glob: 'fonts/**', dot: false } },
303
- { from: { glob: '**/*.jpg', dot: false } },
304
- { from: { glob: '**/*.png', dot: false } },
305
- ], copyIgnore),
306
- new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
297
+ new CopyWebpackPlugin([{ from: { glob: 'assets/**', dot: false } }, { from: { glob: 'fonts/**', dot: false } }, { from: { glob: '**/*.jpg', dot: false } }, { from: { glob: '**/*.png', dot: false } }], copyIgnore),
298
+ new nsWebpack.GenerateNativeScriptEntryPointsPlugin('bundle'),
307
299
  // For instructions on how to set up workers with webpack
308
300
  // check out https://github.com/nativescript/worker-loader
309
301
  new NativeScriptWorkerPlugin(),
@@ -322,36 +314,38 @@ module.exports = env => {
322
314
  memoryLimit: 4096,
323
315
  diagnosticOptions: {
324
316
  syntactic: true,
325
- semantic: true
326
- }
327
- }
328
- })
317
+ semantic: true,
318
+ },
319
+ },
320
+ }),
329
321
  ],
330
322
  };
331
323
 
332
324
  if (report) {
333
325
  // Generate report files for bundles content
334
- config.plugins.push(new BundleAnalyzerPlugin({
335
- analyzerMode: "static",
336
- openAnalyzer: false,
337
- generateStatsFile: true,
338
- reportFilename: resolve(projectRoot, "report", `report.html`),
339
- statsFilename: resolve(projectRoot, "report", `stats.json`),
340
- }));
326
+ config.plugins.push(
327
+ new BundleAnalyzerPlugin({
328
+ analyzerMode: 'static',
329
+ openAnalyzer: false,
330
+ generateStatsFile: true,
331
+ reportFilename: resolve(projectRoot, 'report', `report.html`),
332
+ statsFilename: resolve(projectRoot, 'report', `stats.json`),
333
+ })
334
+ );
341
335
  }
342
336
 
343
337
  if (snapshot) {
344
- config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
345
- chunk: "vendor",
346
- requireModules: [
347
- "@nativescript/core/bundle-entry-points",
348
- ],
349
- projectRoot,
350
- webpackConfig: config,
351
- snapshotInDocker,
352
- skipSnapshotTools,
353
- useLibs
354
- }));
338
+ config.plugins.push(
339
+ new nsWebpack.NativeScriptSnapshotPlugin({
340
+ chunk: 'vendor',
341
+ requireModules: ['@nativescript/core/bundle-entry-points'],
342
+ projectRoot,
343
+ webpackConfig: config,
344
+ snapshotInDocker,
345
+ skipSnapshotTools,
346
+ useLibs,
347
+ })
348
+ );
355
349
  }
356
350
 
357
351
  if (hmr) {