-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
46 lines (43 loc) · 1.24 KB
/
webpack.config.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
const path = require('path');
const { execSync } = require('child_process');
const fetch = require('node-fetch');
const out = path.resolve(__dirname, 'dist');
const filename = 'bundle.js';
class PreviewViaLocalNode {
apply(compiler) {
if (compiler.hooks && compiler.hooks.done) {
compiler.hooks.done.tap('run-on-done', () => {
const hash = execSync(`lightning-node dev store ${out}/${filename}`).toString().split('\t')[0];
console.log('Bundle Hash: ' + hash);
const addr = `http://localhost:4220/services/1/blake3/${hash}`;
fetch(addr).then((res) => {
res.text().then((text) => {
console.log(`\nGET ${addr}`);
console.log(`\n---------\n`);
console.log(text);
console.log(`\n---------\n`);
})
});
});
}
};
}
module.exports = (env) => {
return {
entry: './src/index.js',
mode: "none",
output: {
clean: true,
path: out,
filename,
publicPath: '',
iife: false,
// Hack to bind the main function to the global scope
library: { type: 'window' },
},
plugins: [env.WEBPACK_WATCH ? new PreviewViaLocalNode() : null],
optimization: {
usedExports: true,
},
}
};