File tree 14 files changed +97
-43
lines changed
14 files changed +97
-43
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
2
build
3
+ cache
3
4
lib
4
5
dist
5
6
webpack. * .js
6
7
server.js
7
8
build.js
9
+ init.js
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ node_modules
3
3
dist
4
4
lib
5
5
build
6
+ cache
6
7
.DS_Store
7
8
* .log
8
9
build.js
Original file line number Diff line number Diff line change @@ -4,6 +4,4 @@ Boilerplate app for Electron with Redux
4
4
- electron-compile for ES6/ES7 via babel
5
5
- BrowserSync for livereload
6
6
- Structure for redux/react app
7
-
8
- ** TODO**
9
7
- scripts for building cross-platform releases
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import ReactDOM from 'react-dom' ;
3
+ import { compose , createStore , combineReducers } from 'redux' ;
4
+ import { devTools } from 'redux-devtools' ;
5
+ import { Provider } from 'react-redux' ;
6
+ import user from './reducers/user' ;
7
+ import App from './containers/App' ;
8
+
9
+ const isDevelopment = process . env . NODE_ENV === 'development' ;
10
+ const appCreateStore = isDevelopment ? compose ( devTools ( ) ) ( createStore ) : createStore ;
11
+ const store = appCreateStore ( combineReducers ( { user } ) ) ;
12
+ const rootElement = document . querySelector ( document . currentScript . getAttribute ( 'data-container' ) ) ;
13
+
14
+ ReactDOM . render (
15
+ < div >
16
+ < Provider store = { store } >
17
+ < App />
18
+ </ Provider >
19
+ { isDevelopment && do {
20
+ const { DevTools, DebugPanel, LogMonitor } = require ( 'redux-devtools/lib/react' ) ;
21
+ < DebugPanel top right bottom >
22
+ < DevTools store = { store } monitor = { LogMonitor } />
23
+ < / D e b u g P a n e l > ;
24
+ } }
25
+ </div > ,
26
+ rootElement
27
+ ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { handleActions } from 'redux-actions';
2
2
3
3
export default handleActions ( {
4
4
USER_LOGIN : ( state , action ) => {
5
- console . log ( state , action ) ;
6
5
return { ...state , ...action . payload } ;
7
6
}
8
7
} , { } ) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ app.on('ready', () => {
18
18
mainWindow = new BrowserWindow ( { width : 1200 , height : 1000 } ) ;
19
19
20
20
mainWindow . loadUrl ( `file://${ __dirname } /client/index.html` ) ;
21
- mainWindow . openDevTools ( ) ;
21
+
22
+ if ( process . env . NODE_ENV === 'development' ) {
23
+ mainWindow . openDevTools ( ) ;
24
+ }
22
25
23
26
mainWindow . on ( 'closed' , ( ) => {
24
27
mainWindow = null ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- // TODO: precompile in prod, remove init?
2
- require ( 'electron-compile' ) . init ( ) ;
3
- require ( './main' ) ;
1
+ var path = require ( 'path' ) ;
2
+ var cacheDir = path . join ( __dirname , 'cache' ) ;
3
+
4
+ if ( process . env . NODE_ENV === 'development' ) {
5
+ require ( 'electron-compile' ) . initWithOptions ( {
6
+ cacheDir : cacheDir ,
7
+ js : {
8
+ stage : 2
9
+ }
10
+ } ) ;
11
+ } else {
12
+ require ( 'electron-compile' ) . initForProduction ( cacheDir ) ;
13
+ }
14
+ require ( './app/main' ) ;
15
+
Original file line number Diff line number Diff line change 11
11
"react-dom" : " ^0.14.0-rc1" ,
12
12
"react-redux" : " ^2.1.2" ,
13
13
"redux" : " ^3.0.0" ,
14
- "redux-actions" : " ^0.8.0"
14
+ "redux-actions" : " ^0.8.0" ,
15
+ "electron-compile" : " ^0.9.2" ,
16
+ "redux-devtools" : " ^2.1.2"
15
17
},
16
18
"devDependencies" : {
17
19
"babel" : " ^5.8.23" ,
18
20
"babel-eslint" : " ^4.1.1" ,
19
21
"browser-sync" : " ^2.9.3" ,
20
- "electron-compile " : " ^0.9.2 " ,
22
+ "electron-packager " : " ^5.1.0 " ,
21
23
"electron-prebuilt" : " ^0.32.2" ,
22
24
"eslint" : " ^1.4.1" ,
23
25
"eslint-config-airbnb" : " 0.0.8" ,
24
- "eslint-plugin-react" : " ^3.3.2" ,
25
- "redux-devtools" : " ^2.1.2"
26
+ "eslint-plugin-react" : " ^3.3.2"
26
27
},
27
28
"scripts" : {
28
- "start" : " node node_modules/babel/bin/babel-node.js scripts/serve.js"
29
+ "serve" : " node node_modules/babel/bin/babel-node.js scripts/serve.js" ,
30
+ "pack" : " node node_modules/babel/bin/babel-node.js scripts/pack.js"
29
31
}
30
32
}
Original file line number Diff line number Diff line change
1
+ import fs from 'fs' ;
2
+ import path from 'path' ;
3
+ import packager from 'electron-packager' ;
4
+ // elctron-compile api not setup for es6 modules, need to use require;
5
+ const compiler = require ( 'electron-compile' ) ;
6
+
7
+ const paths = {
8
+ packageJson : path . join ( __dirname , '../package.json' ) ,
9
+ cache : path . join ( __dirname , '../cache' )
10
+ } ;
11
+
12
+ const packageJson = JSON . parse ( fs . readFileSync ( paths . packageJson , 'utf8' ) ) ;
13
+ const nodeModuleIgnores = [
14
+ 'electron-compile/node_modules/electron-compilers' ,
15
+ // devDependencies are ignored by default but explicity ignoring them
16
+ // seems to speed up packaging
17
+ ...Object . keys ( packageJson . devDependencies ) ,
18
+ ] ;
19
+
20
+ compiler . init ( paths . cache ) ;
21
+ compiler . compileAll ( 'app' ) ;
22
+ fs . writeFileSync (
23
+ path . join ( paths . cache , 'settings.json' ) ,
24
+ JSON . stringify ( compiler . collectCompilerInformation ( ) )
25
+ ) ;
26
+
27
+ packager ( {
28
+ dir : '.' ,
29
+ name : packageJson . name ,
30
+ platform : 'darwin' ,
31
+ arch : 'x64' ,
32
+ version : '0.32.2' ,
33
+ overwrite : true ,
34
+ prune : true ,
35
+ ignore : new RegExp ( `node_modules/(${ nodeModuleIgnores . join ( '|' ) } )` ) ,
36
+ // asar: true,
37
+ out : 'dist'
38
+ } , ( err , appPath ) => {
39
+ if ( err ) return console . error ( err ) ;
40
+ console . log ( appPath ) ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments