Skip to content

Commit 80f6cfc

Browse files
committed
Update build to include dev script for hot reload
1 parent 91b8745 commit 80f6cfc

File tree

5 files changed

+617
-728
lines changed

5 files changed

+617
-728
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"main": "lib/index.js",
1010
"scripts": {
11-
"build": "npx webpack",
11+
"dev": "npx webpack --watch",
12+
"build": "npx webpack --mode production",
1213
"lint": "npx eslint src",
1314
"test": "npx jest",
1415
"publish": "npm publish",

src/builder/webpack_config/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ export default class WebpackConfig {
5959
injectDevScript(configs) {
6060
configs.main.plugins.push(
6161
new InjectPlugin(() => {
62-
return fs
63-
.readFileSync(
64-
path.resolve(__dirname, '..', 'src', 'dev', 'reload.js')
65-
)
66-
.toString()
62+
return fs.readFileSync(path.resolve(__dirname, 'dev.js')).toString()
6763
})
6864
)
6965
}

src/dev/reload.js src/dev/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ fs.watch(path.resolve(__dirname, '..', 'renderer'), {}, reloadRenderer)
3131

3232
// Disable main process reloading for now
3333
// fs.watch(path.resolve(__dirname, '..', 'preload'), {}, reloadMain)
34-
fs.watch(path.resolve(__dirname), {}, reloadMain)
34+
// fs.watch(path.resolve(__dirname), {}, reloadMain)

webpack.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ const path = require('path')
22
const nodeExternals = require('webpack-node-externals')
33

44
module.exports = {
5-
entry: path.resolve(__dirname, 'src', 'index.js'),
5+
entry: {
6+
index: path.resolve(__dirname, 'src', 'index.js'),
7+
dev: path.resolve(__dirname, 'src', 'dev', 'index.js')
8+
},
69
mode: 'development',
710
target: 'node',
811
node: {
@@ -12,7 +15,6 @@ module.exports = {
1215
externals: [nodeExternals()],
1316
output: {
1417
path: path.resolve(__dirname, 'dist'),
15-
filename: 'index.js',
1618
libraryTarget: 'commonjs2'
1719
},
1820
resolve: {

0 commit comments

Comments
 (0)