1 |
|
2 | const File = require('vinyl');
|
3 | const ansiHTML = require('ansi-html');
|
4 |
|
5 | const template =
|
6 | '<head><style>' +
|
7 | 'body{padding:20px;font:18px monospace;background:#880000;color:#fff;}' +
|
8 | '</style></head>';
|
9 |
|
10 | ansiHTML.setColors({
|
11 | reset: ['fff', '800'],
|
12 | black: 'aaa',
|
13 | red: '9ff',
|
14 | green: 'f9f',
|
15 | yellow: '99f',
|
16 | blue: 'ff9',
|
17 | magenta: 'f99',
|
18 | cyan: '9f9',
|
19 | lightgrey: 'ccc',
|
20 | darkgrey: 'aaa'
|
21 | });
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | function errorPage(error) {
|
29 | let errorText = error.toString();
|
30 | console.error(error);
|
31 | if (error.codeFrame) {
|
32 | errorText += '<pre>' + ansiHTML(error.codeFrame) + '</pre>';
|
33 | }
|
34 | return new File({
|
35 | path: 'index.html',
|
36 | contents: new Buffer(template + errorText)
|
37 | });
|
38 | }
|
39 |
|
40 | module.exports = errorPage;
|