|
1 | 1 | const fs = require('fs') |
2 | 2 | const { DefinePlugin } = require('webpack') |
3 | 3 |
|
4 | | -async function chainWebpack (api, pluginOptions, config) { |
| 4 | +async function chainWebpack(api, pluginOptions, config) { |
5 | 5 | const rendererProcessChain = |
6 | 6 | pluginOptions.chainWebpackRendererProcess || (config => config) |
7 | 7 | const realDirname = 'require("electron").remote.app.getAppPath()' |
8 | 8 | if (process.env.IS_ELECTRON) { |
9 | | - // Add externals |
10 | | - config.externals(getExternals(api, pluginOptions)) |
11 | | - // Modify webpack config to work properly with electron |
12 | | - config |
13 | | - .target('electron-renderer') |
14 | | - .node.set('__dirname', false) |
15 | | - .set('__filename', false) |
| 9 | + if (pluginOptions.nodeIntegration) { |
| 10 | + // Add externals |
| 11 | + config.externals(getExternals(api, pluginOptions)) |
| 12 | + // Modify webpack config to work properly with electron |
| 13 | + config.target('electron-renderer') |
| 14 | + } |
| 15 | + config.node.set('__dirname', false).set('__filename', false) |
16 | 16 | // Set IS_ELECTRON |
17 | 17 | if (config.plugins.has('define')) { |
18 | 18 | config.plugin('define').tap(args => { |
@@ -76,7 +76,7 @@ async function chainWebpack (api, pluginOptions, config) { |
76 | 76 | process.env.VUE_APP_NODE_MODULES_PATH = false |
77 | 77 | } |
78 | 78 | // Find all the dependencies without a `main` property or with a `binary` property or set by user and add them as webpack externals |
79 | | -function getExternals (api, pluginOptions) { |
| 79 | +function getExternals(api, pluginOptions) { |
80 | 80 | const nodeModulesPath = pluginOptions.nodeModulesPath || './node_modules' |
81 | 81 | let nodeModulesPaths = [] |
82 | 82 | if (Array.isArray(nodeModulesPath)) { |
|
0 commit comments