-
Notifications
You must be signed in to change notification settings - Fork 800
/
webpack.watch.js
38 lines (35 loc) · 1.08 KB
/
webpack.watch.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
// TODO: this is broken because webpack-extension-reloader does not support webpack 5.
const path = require('path');
const merge = require('webpack-merge');
const dev = require('./webpack.dev.js');
const ExtensionReloader = require('webpack-extension-reloader');
const {exec} = require('child_process');
// after compiling, the tests will automatically be run each time a file change occurs
const runTestsAfterBuild = () => {
return {
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
// leave as node otherwise browser does not launch
exec('node scripts/test-runner.js', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
}
}
};
module.exports = merge(dev, {
mode: 'development',
plugins: [
new ExtensionReloader(),
runTestsAfterBuild(),
],
watch: true,
watchOptions: {
ignored: /node_modules/
},
output: {
path: path.resolve(__dirname, 'test/chrome/dist'),
publicPath: '/test/chrome/dist/'
}
});