Skip to content

Commit e16795f

Browse files
committed
Conditionally importing webpack for web vs native
1 parent 8a92b25 commit e16795f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ const TerserPlugin = require('terser-webpack-plugin');
1212
const VueLoaderPlugin = require('vue-loader/lib/plugin');
1313
const NsVueTemplateCompiler = require('nativescript-vue-template-compiler');
1414

15-
const nsWebpack = require('@nativescript/webpack');
16-
const nativescriptTarget = require('@nativescript/webpack/nativescript-target');
1715
const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
1816

1917
const hashSalt = Date.now().toString();
2018

2119
const DefinePlugin = require('webpack/lib/DefinePlugin');
2220

21+
let nsWebpack
22+
let nativescriptTarget
23+
2324
// // // TO BE REMOVED SOON
2425
// // // // eslint-disable-next-line prefer-destructuring
2526
// // // const PlatformFSPlugin = nsWebpack.PlatformFSPlugin;
@@ -146,6 +147,11 @@ module.exports = (api, projectOptions) => {
146147
// throw new Error('You need to provide a target platform!');
147148
}
148149

150+
if(platform !== 'web') {
151+
nsWebpack = require('@nativescript/webpack');
152+
nativescriptTarget = require('@nativescript/webpack/nativescript-target');
153+
}
154+
149155
const projectRoot = api.service.context;
150156
const appMode = platform === 'android' ? 'native' : platform === 'ios' ? 'native' : 'web';
151157

0 commit comments

Comments
 (0)