Skip to content

Commit 8674dac

Browse files
fix(overmind-devtools): fix issue with electron
1 parent aaab190 commit 8674dac

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

packages/node_modules/overmind-devtools/bin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const serverPath = path.join(__dirname, 'src/main.js')
88

99
const args = [serverPath]
1010
.concat([].concat(process.argv).splice(2))
11-
.concat('--not-packaged=true')
11+
// .concat('--not-packaged=true')
1212

1313
const env = Object.create(process.env)
1414
env.NODE_ENV = 'production'

packages/node_modules/overmind-devtools/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"overmind-devtools": "bin.js"
1010
},
1111
"scripts": {
12-
"start": "electron ./src/main",
12+
"start": "electron ./src/main",
13+
"prod": "NODE_ENV=production electron ./src/main --not-packaged=true",
1314
"build": "rimraf devtoolsDist && cp -R ../overmind-devtools-client/dist devtoolsDist"
1415
},
1516
"keywords": [

packages/node_modules/overmind-devtools/src/main.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ function createWindow() {
1717
minWidth: 500,
1818
})
1919

20+
electron.protocol.registerFileProtocol('filestub', (request, callback) => {
21+
const url = request.url.substr(10)
22+
const file = { path: path.normalize(`${path.join(__dirname, '..')}/${url}`) }
23+
24+
callback(file)
25+
})
26+
2027
const devtoolBackend = DevtoolBackend.create({
2128
onRelaunch() {
2229
app.relaunch()
@@ -61,18 +68,15 @@ function createWindow() {
6168

6269
function openDevtools(port) {
6370
if (process.env.NODE_ENV === 'production') {
64-
mainWindow.loadURL(
65-
'data:text/html;charset=UTF-8,' +
66-
encodeURIComponent(
67-
devtoolBackend.getMarkup('bundle.js', port, onPortSubmit, onRestart)
68-
),
69-
{
70-
baseURLForDataURL: `file://${path.join(
71-
__dirname,
72-
'..'
73-
)}/devtoolsDist/`,
74-
}
75-
)
71+
mainWindow.loadURL(
72+
'data:text/html;charset=UTF-8,' +
73+
encodeURIComponent(
74+
devtoolBackend.getMarkup('bundle.js', port, onPortSubmit, onRestart)
75+
),
76+
{
77+
baseURLForDataURL: `filestub://devtoolsDist/`,
78+
}
79+
)
7680
} else {
7781
mainWindow.loadURL('http://localhost:8080')
7882
mainWindow.webContents.openDevTools()

0 commit comments

Comments
 (0)