forked from open-source-labs/Swell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.development.js
54 lines (53 loc) · 1.49 KB
/
webpack.development.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const merge = require('webpack-merge').merge;
const base = require('./webpack.config');
const { spawn } = require('child_process');
module.exports = merge(base, {
mode: 'development',
devtool: 'source-map',
devServer: {
host: '127.0.0.1',
port: '8080',
open: '/dev',
hot: true,
compress: true,
proxy: {
'/webhookServer': {
target: 'http://localhost:3000',
},
'/webhook': {
target: 'http://localhost:3000',
},
'/api': {
target: 'http://localhost:3000',
/**
* @todo Change secure option to true, and refactor code to account for
* change
*/
secure: false,
},
},
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
middlewares.unshift({
// unshift does not work, ends in infinite calls to this function
name: 'run-in-electron',
path: '/dev',
middleware: (req, res) => {
spawn('npx electron --dev .', {
shell: true,
env: process.env,
stdio: 'inherit',
})
.on('close', () => process.exit(130))
.on('error', (spawnError) => console.error(spawnError));
return res
.status(200)
.send('Opened the Electron app in development mode.');
},
});
return middlewares;
},
},
});