1 |
|
2 | "use strict";
|
3 |
|
4 | let prettyError;
|
5 |
|
6 | function getPrettyError() {
|
7 | if (!prettyError) {
|
8 |
|
9 | const PrettyError = require("pretty-error");
|
10 | prettyError = new PrettyError();
|
11 | prettyError.withoutColors();
|
12 | prettyError.skipPackage("html-plugin-evaluation");
|
13 | prettyError.skipNodeFiles();
|
14 | prettyError.skip(function (traceLine) {
|
15 | return traceLine.path === "html-plugin-evaluation";
|
16 | });
|
17 | }
|
18 | return prettyError;
|
19 | }
|
20 |
|
21 | module.exports = function (err, context) {
|
22 | return {
|
23 | toHtml: function () {
|
24 | return "Html Webpack Plugin:\n<pre>\n" + this.toString() + "</pre>";
|
25 | },
|
26 | toJsonHtml: function () {
|
27 | return JSON.stringify(this.toHtml());
|
28 | },
|
29 | toString: function () {
|
30 | try {
|
31 | return getPrettyError()
|
32 | .render(err)
|
33 | .replace(/webpack:\/\/\/\./g, context);
|
34 | } catch (e) {
|
35 |
|
36 |
|
37 |
|
38 | return err;
|
39 | }
|
40 | },
|
41 | };
|
42 | };
|