Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Setup Devtools #26

Merged
merged 4 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ extension_chrome/js/
extension_chrome/css/
extension_chrome.zip

electron/js/
electron/js/*
!electron/js/main.js
electron/dist
electron/Comics Reader-linux-ia32

Expand Down
24 changes: 21 additions & 3 deletions src/platform/electron/main.js → electron/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const electron = require('electron');
const windowStateKeeper = require('electron-window-state');
const {app, session, BrowserWindow} = electron;

const installExtension = require('electron-devtools-installer').default;
const { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = require('electron-devtools-installer');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
Expand All @@ -23,16 +26,31 @@ function createWindow () {
icon: __dirname + '/Icon.ico',
darkTheme: true,
autoHideMenuBar: true,
titleBarStyle: 'hidden-inset'
titleBarStyle: 'hidden-inset',
webPreferences: {
webSecurity: false
}
});

// Let us register listeners on the window, so we can update the state
// automatically (the listeners will be removed when the window is closed)
// and restore the maximized or full screen state
mainWindowState.manage(mainWindow);

// and load the index.html of the app.
mainWindow.loadURL(`file://${app.getAppPath()}/index.html`);

if (process.env.NODE_ENV === 'development') {
// and load the index.html of the app.
mainWindow.loadURL('http://localhost:8080');

installExtension(REACT_DEVELOPER_TOOLS).then(() => {
installExtension(REDUX_DEVTOOLS).then(() => {
mainWindow.openDevTools();
});
});
} else {
// and load the index.html of the app.
mainWindow.loadURL(`file://${app.getAppPath()}/index.html`);
}

// Open the DevTools.
// mainWindow.webContents.openDevTools();
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"product": "webpack --config webpack.product.config.js --progress --colors --watch",
"dev": "webpack --config webpack.config.js --progress --colors --watch",
"dev:electron": "webpack-dev-server --content-base electron/ --inline --hot --colors",
"zip": "zip extension_chrome.zip -r ./extension_chrome/ -x \"*/.*\""
},
"devDependencies": {
Expand Down Expand Up @@ -45,6 +46,7 @@
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.2",
"webpack-livereload-plugin": "^0.8.1"
},
"dependencies": {
Expand All @@ -68,6 +70,7 @@
"react-router-redux": "^4.0.5",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.5.2",
"redux-devtools-extension": "^1.0.0",
"redux-logger": "^2.6.1",
"redux-persist": "^4.0.0-alpha5",
"redux-saga": "^0.11.1",
Expand Down
21 changes: 14 additions & 7 deletions src/store/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ import createLogger from 'redux-logger';
import { history } from 'services';
import { routerMiddleware } from 'react-router-redux';
import { persistStore, autoRehydrate } from 'redux-persist';
import { composeWithDevTools } from 'redux-devtools-extension';

const logger = createLogger();

export default function configureStore(initialState) {
const sagaMiddleware = createSagaMiddleware();

const createStoreWithMiddleware = applyMiddleware(
sagaMiddleware,
thunk,
logger,
routerMiddleware(history)
)(createStore);
const store = createStore(
reducer,
initialState,
composeWithDevTools(
applyMiddleware(
sagaMiddleware,
thunk,
logger,
routerMiddleware(history)
),
autoRehydrate()
)
);

const store = createStoreWithMiddleware(reducer, initialState, autoRehydrate());
persistStore(store);

store.runSaga = sagaMiddleware.run;
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ module.exports = [
Object.assign({}, baseConfig, {
name: 'electron',
entry: {
app:'./src/app.js',
main:'./src/platform/electron/main.js'
app:'./src/app.js'
},
output: {
path: path.join(__dirname, 'electron/js'),
Expand Down
Loading