Skip to content

Commit fdba1fd

Browse files
authored
New packager (#16)
Integrate electron-builder
1 parent 7c851e2 commit fdba1fd

File tree

10 files changed

+73
-113
lines changed

10 files changed

+73
-113
lines changed

.babelrc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"presets": ["es2015", "stage-0", "react"],
3-
"plugins": ["transform-decorators-legacy", "transform-runtime"],
4-
"sourceMaps": "inline",
5-
"retainLines": true
3+
"plugins": ["transform-decorators-legacy", "transform-runtime"]
64
}

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
logs
21
node_modules
32
dist
4-
lib
53
build
6-
cache
74
.DS_Store
85
*.log
9-
build.js
10-
_old_
11-
.cache

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"search.exclude": {
3+
"build/": true,
4+
"dist/": true
5+
}
6+
}

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
##Boilerplate app for Electron with Redux/React
22

3-
- electron-compile for ES6/ES7 via babel
3+
- ES6/ES7 via babel
44
- BrowserSync for livereload
55
- structure for redux/react app
66
- scripts for building cross-platform releases
77

88
####Commands
99
- `npm run serve` - Start electron app in development
10-
- `npm run pack` - Create a package for distribution. Will name the package based on name in package.json. **Note:** Move the package out of `/dist` to run (see [Issue #2](https://github.com/jschr/electron-react-redux-boilerplate/issues/2))
10+
- `npm run pack` - Create a package for distribution for macOS, Windows and Linux.
11+
- `npm run pack:mac` - Create a package for distribution for macOS only.
12+
- `npm run pack:win` - Create a package for distribution for Windows only.
13+
- `npm run pack:linux` - Create a package for distribution for Linux only.

main.js app/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ app.on('ready', async () => {
5252
});
5353

5454
mainWindow.loadURL(url.format({
55-
pathname: path.join(__dirname, 'app/index.html'),
55+
pathname: path.join(__dirname, 'index.html'),
5656
protocol: 'file:',
5757
slashes: true
5858
}));

electron-builder.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
appId: com.example.app
2+
copyright: Example co
3+
productName: MyApp
4+
5+
asar: true
6+
7+
directories:
8+
buildResources: build-assets/
9+
output: dist/
10+
11+
files:
12+
- package.json
13+
- init.js
14+
- build/
15+
- node_modules/
16+
17+
dmg:
18+
contents:
19+
- type: link
20+
path: /Applications
21+
x: 410
22+
y: 150
23+
- type: file
24+
x: 130
25+
y: 150
26+
27+
mac:
28+
target: dmg
29+
category: public.app-category.tools
30+
31+
win:
32+
target: nsis
33+
34+
linux:
35+
target:
36+
- deb
37+
- AppImage

init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require('electron-compile').init(__dirname, './main');
1+
require('./build/main');

package.json

+21-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"version": "0.0.0",
44
"description": "electron-react-redux-boilerplate",
55
"main": "init.js",
6-
"author": "Jordan Schroter",
6+
"author": {
7+
"name": "Jordan Schroter",
8+
"email": "[email protected]"
9+
},
710
"repository": "https://github.com/jschr/electron-react-redux-boilerplate",
811
"license": "MIT",
912
"dependencies": {
1013
"babel-runtime": "^6.22.0",
11-
"electron-compile": "^5.1.3",
1214
"react": "^15.4.2",
1315
"react-dom": "^15.4.2",
1416
"react-redux": "^5.0.2",
@@ -31,18 +33,30 @@
3133
"browser-sync": "^2.9.3",
3234
"chai": "^3.4.1",
3335
"electron": "^1.5.0",
34-
"electron-compilers": "^5.1.3",
36+
"electron-builder": "^12.3.1",
3537
"electron-devtools-installer": "^2.1.0",
36-
"electron-packager": "^8.5.1",
3738
"eslint": "^3.14.1",
3839
"eslint-plugin-react": "^6.9.0",
3940
"mocha": "^3.2.0",
41+
"npm-run-all": "^4.0.1",
4042
"rimraf": "^2.5.4"
4143
},
4244
"scripts": {
43-
"serve": "babel-node scripts/serve.js",
44-
"pack": "babel-node scripts/pack.js",
45+
"postinstall": "install-app-deps",
46+
"serve": "npm run private:compile -- --source-maps true && run-p -r private:watch private:serve",
4547
"test": "mocha -R spec --compilers js:babel-core/register",
46-
"lint": "eslint --no-ignore scripts app test *.js"
48+
"lint": "eslint --no-ignore scripts app test *.js",
49+
"pack": "run-s private:clean private:compile private:build:all",
50+
"pack:mac": "run-s private:clean private:compile private:build:mac",
51+
"pack:win": "run-s private:clean private:compile private:build:win",
52+
"pack:linux": "run-s private:clean private:compile private:build:linux",
53+
"private:build:all": "build -mwl",
54+
"private:build:mac": "build --mac",
55+
"private:build:win": "build --win",
56+
"private:build:linux": "build --linux",
57+
"private:watch": "npm run private:compile -- --source-maps true --watch --skip-initial-build",
58+
"private:serve": "babel-node scripts/serve.js",
59+
"private:compile": "babel app/ --copy-files --out-dir build",
60+
"private:clean": "rimraf build"
4761
}
4862
}

scripts/pack.js

-92
This file was deleted.

scripts/serve.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ bsync.init({
4747
});
4848

4949
bsync
50-
.watch('app/**/*')
50+
.watch('build/**/*')
5151
.on('change', bsync.reload);
5252
});

0 commit comments

Comments
 (0)