-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,9 +130,20 @@ module.exports = (api, options) => { | |
// Build the render process with the custom args | ||
await api.service.run('build', vueArgs) | ||
// Copy package.json to output dir | ||
fs.copySync( | ||
api.resolve('./package.json'), | ||
`${outputDir}/bundled/package.json` | ||
const pkg = JSON.parse( | ||
fs.readFileSync(api.resolve('./package.json'), 'utf8') | ||
) | ||
const externals = getExternals(api, pluginOptions) | ||
// https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/223 | ||
// Strip non-externals from dependencies so they won't be copied into app.asar | ||
Object.keys(pkg.dependencies).forEach(dependency => { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nklayman
Author
Owner
|
||
if (!Object.keys(externals).includes(dependency)) { | ||
delete pkg.dependencies[dependency] | ||
} | ||
}) | ||
fs.writeFileSync( | ||
`${outputDir}/bundled/package.json`, | ||
JSON.stringify(pkg, 2) | ||
) | ||
// Prevent electron-builder from installing app deps | ||
fs.ensureDirSync(`${outputDir}/bundled/node_modules`) | ||
|
@nklayman this line produces error in situation when
package.json
has nodependencies
It's a good practice (for Electron with Webpack) to move all
dependencies
todevDependencies
, becausewebpack
produces dist files of our app as bundle.This practice prevents bloating app in size by
electron-builder
which includes every single dependency stated independencies
section ofpackage.json
, including nested dependencies, even if they not used at all.Detailed info may be found here: https://github.com/michalzaq12/electron-nuxt#dependencies-vs-devdependencies