Skip to content

Commit 7b439b5

Browse files
committed
Make the electron shell work without previous extension hook
1 parent cae43ea commit 7b439b5

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

shells/electron/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
connect: () => {
3+
require('./build/hook.js')
34
require('./build/backend.js')
45
}
56
}

shells/electron/server.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ const app = require('express')()
22
const http = require('http').Server(app)
33
const io = require('socket.io')(http)
44
const path = require('path')
5+
const fs = require('fs')
56

67
const port = process.env.PORT || 8098
78

89
app.get('/', function (req, res) {
9-
res.sendFile(path.join(__dirname, '/build/backend.js'))
10+
const hookContent = fs.readFileSync(path.join(__dirname, '/build/hook.js'), 'utf8')
11+
const backendContent = fs.readFileSync(path.join(__dirname, '/build/backend.js'), 'utf8')
12+
res.send([hookContent, backendContent].join('\n'))
1013
})
1114

1215
// Middleman

shells/electron/src/backend.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import io from 'socket.io-client'
22
import { initBackend } from 'src/backend'
3-
import { installHook } from 'src/backend/hook'
43
import Bridge from 'src/bridge'
54

65
(function () {
@@ -21,10 +20,6 @@ import Bridge from 'src/bridge'
2120
socket.disconnect()
2221
})
2322

24-
if (!window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
25-
installHook(window)
26-
}
27-
2823
initBackend(bridge)
2924
socket.emit('vue-devtools-init')
3025
}())

shells/electron/src/hook.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { installHook } from 'src/backend/hook'
2+
3+
if (!window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
4+
installHook(window)
5+
}

shells/electron/webpack.config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ module.exports = {
1212
entry: {
1313
devtools: './src/devtools.js',
1414
backend: './src/backend.js',
15+
hook: './src/hook.js'
1516
},
1617
output: {
1718
path: __dirname + '/build',
1819
publicPath: '/build/',
19-
filename: '[name].js',
20+
filename: '[name].js'
2021
},
2122
resolve: {
2223
alias
@@ -25,7 +26,7 @@ module.exports = {
2526
rules: [
2627
{
2728
test: /\.js$/,
28-
loader: 'buble-loader',
29+
loader: 'buble-loader',
2930
exclude: /node_modules|vue\/dist|vuex\/dist/,
3031
options: bubleOptions
3132
},
@@ -47,8 +48,5 @@ module.exports = {
4748
hints: false
4849
},
4950
devtool: '#cheap-module-source-map',
50-
devServer: {
51-
quiet: true
52-
},
53-
plugins: process.env.VUE_DEVTOOL_TEST ? [] :[new FriendlyErrorsPlugin()]
51+
plugins: process.env.VUE_DEVTOOL_TEST ? [] : [new FriendlyErrorsPlugin()]
5452
}

0 commit comments

Comments
 (0)