Merge pull request #129 from feross/app-size
Shrink Electron bundle by MBs!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# <img src="WebTorrent.png" width="35"> WebTorrent.app
|
||||
# <img src="static/WebTorrent.png" width="35"> WebTorrent.app
|
||||
|
||||
[![Gitter][webtorrent-gitter-image]][webtorrent-gitter-url]
|
||||
[![Travis Build][webtorrent-app-travis-image]][webtorrent-app-travis-url]
|
||||
|
||||
@@ -25,7 +25,7 @@ var all = {
|
||||
// Package the application's source code into an archive, using Electron's archive
|
||||
// format. Mitigates issues around long path names on Windows and slightly speeds up
|
||||
// require().
|
||||
asar: false,
|
||||
asar: true,
|
||||
|
||||
// The build version of the application. Maps to the FileVersion metadata property on
|
||||
// Windows, and CFBundleVersion on OS X. We're using the short git hash (e.g. 'e7d837e')
|
||||
@@ -33,7 +33,7 @@ var all = {
|
||||
|
||||
// Pattern which specifies which files to ignore when copying files to create the
|
||||
// package(s).
|
||||
ignore: /^\/(dist|static\/screenshot.png)$/,
|
||||
ignore: /^\/dist|\/(appveyor.yml|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|\.[^\/]*|.*\.md|.*\.markdown)$/,
|
||||
|
||||
// The application name.
|
||||
name: config.APP_NAME,
|
||||
@@ -66,7 +66,7 @@ var darwin = {
|
||||
'helper-bundle-id': 'io.webtorrent.app.helper',
|
||||
|
||||
// Application icon.
|
||||
icon: path.join(__dirname, '..', 'WebTorrent.icns')
|
||||
icon: path.join(__dirname, '..', 'static', 'WebTorrent.icns')
|
||||
}
|
||||
|
||||
var win32 = {
|
||||
@@ -100,7 +100,7 @@ var win32 = {
|
||||
},
|
||||
|
||||
// Application icon.
|
||||
icon: path.join(__dirname, '..', 'WebTorrent.ico')
|
||||
icon: path.join(__dirname, '..', 'static', 'WebTorrent.ico')
|
||||
}
|
||||
|
||||
var linux = {
|
||||
@@ -109,11 +109,33 @@ var linux = {
|
||||
// Note: Application icon for Linux is specified via the BrowserWindow `icon` option.
|
||||
}
|
||||
|
||||
electronPackager(Object.assign({}, all, darwin), done)
|
||||
electronPackager(Object.assign({}, all, win32), done)
|
||||
electronPackager(Object.assign({}, all, linux), done)
|
||||
var platform = process.argv[2]
|
||||
|
||||
function done (err, appPath) {
|
||||
if (platform === '--darwin') {
|
||||
buildDarwin()
|
||||
} else if (platform === '--win32') {
|
||||
buildWin32()
|
||||
} else if (platform === '--linux') {
|
||||
buildLinux()
|
||||
} else {
|
||||
// Build all
|
||||
buildDarwin(() => buildWin32(() => buildLinux()))
|
||||
}
|
||||
|
||||
function buildDarwin (cb) {
|
||||
electronPackager(Object.assign({}, all, darwin), done.bind(null, cb))
|
||||
}
|
||||
|
||||
function buildWin32 (cb) {
|
||||
electronPackager(Object.assign({}, all, win32), done.bind(null, cb))
|
||||
}
|
||||
|
||||
function buildLinux (cb) {
|
||||
electronPackager(Object.assign({}, all, linux), done.bind(null, cb))
|
||||
}
|
||||
|
||||
function done (cb, err, appPath) {
|
||||
if (err) console.error(err.message || err)
|
||||
else console.log('Built ' + appPath)
|
||||
if (cb) cb()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ var path = require('path')
|
||||
|
||||
module.exports = {
|
||||
APP_NAME: 'WebTorrent',
|
||||
APP_ICON: path.join(__dirname, 'WebTorrent.png'),
|
||||
APP_ICON: path.join(__dirname, 'static', 'WebTorrent.png'),
|
||||
INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'),
|
||||
SOUND_ADD: 'file://' + path.join(__dirname, 'static', 'sound', 'add.wav'),
|
||||
SOUND_DELETE: 'file://' + path.join(__dirname, 'static', 'sound', 'delete.wav'),
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
"scripts": {
|
||||
"cleanup": "node ./bin/cleanup.js",
|
||||
"debug": "DEBUG=* electron .",
|
||||
"package": "node ./bin/package.js",
|
||||
"package": "npm prune && npm dedupe && node ./bin/package.js",
|
||||
"size": "npm run package -- --darwin && du -ch dist/WebTorrent-darwin-x64 | grep total",
|
||||
"start": "electron .",
|
||||
"test": "standard",
|
||||
"update-authors": "./bin/update-authors.sh"
|
||||
|
||||
@@ -615,7 +615,6 @@ function onWarning (err) {
|
||||
}
|
||||
|
||||
function showDoneNotification (torrent) {
|
||||
console.log(state.window.isFocused)
|
||||
if (state.window.isFocused) return
|
||||
|
||||
var notif = new window.Notification('Download Complete', {
|
||||
|
||||
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Reference in New Issue
Block a user