UNPKG

913 BJavaScriptView Raw
1// @ts-nocheck
2'use strict';
3const PrettyError = require('pretty-error');
4const prettyError = new PrettyError();
5prettyError.withoutColors();
6prettyError.skipPackage('html-plugin-evaluation');
7prettyError.skipNodeFiles();
8prettyError.skip(function (traceLine) {
9 return traceLine.path === 'html-plugin-evaluation';
10});
11
12module.exports = function (err, context) {
13 return {
14 toHtml: function () {
15 return 'Html Webpack Plugin:\n<pre>\n' + this.toString() + '</pre>';
16 },
17 toJsonHtml: function () {
18 return JSON.stringify(this.toHtml());
19 },
20 toString: function () {
21 try {
22 return prettyError.render(err).replace(/webpack:\/\/\/\./g, context);
23 } catch (e) {
24 // This can sometimes fail. We don't know why, but returning the
25 // original error is better than returning the error thrown by
26 // pretty-error.
27 return err;
28 }
29 }
30 };
31};