├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── _sandbox ├── .eslintrc ├── .gitignore ├── index.js ├── package.json ├── watch.js └── webpack.config.js ├── appveyor.yml ├── index.js ├── package.json ├── src ├── core │ ├── extractWebpackError.js │ ├── formatErrors.js │ └── transformErrors.js ├── formatters │ ├── defaultError.js │ ├── eslintError.js │ └── moduleNotFound.js ├── friendly-errors-plugin.js ├── reporters │ ├── base.js │ ├── consola.js │ └── index.js ├── transformers │ ├── babelSyntax.js │ ├── esLintError.js │ └── moduleNotFound.js └── utils │ ├── index.js │ └── log.js ├── test ├── fixtures │ ├── .gitignore │ ├── babel-syntax │ │ ├── index.js │ │ └── webpack.config.js │ ├── eslint-warnings │ │ ├── .eslintrc │ │ ├── index.js │ │ ├── module.js │ │ └── webpack.config.js │ ├── module-errors │ │ ├── index.js │ │ └── webpack.config.js │ ├── multi-compiler-module-errors │ │ ├── index.js │ │ ├── index2.js │ │ └── webpack.config.js │ ├── multi-compiler-success │ │ ├── index.js │ │ ├── index2.js │ │ └── webpack.config.js │ └── success │ │ ├── index.js │ │ └── webpack.config.js ├── integration.spec.js ├── unit │ ├── formatErrors.spec.js │ ├── formatters │ │ ├── defaultError.spec.js │ │ └── moduleNotFound.spec.js │ ├── plugin │ │ └── friendlyErrors.spec.js │ ├── transformers │ │ ├── babelSyntax.spec.js │ │ └── moduleNotFound.spec.js │ └── utils │ │ └── utils.spec.js └── utils │ └── index.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "only": ["test/"], 3 | "plugins": ["transform-async-to-generator"] 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test/fixtures -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "standard", 3 | "env": { 4 | "jest": true 5 | } 6 | }; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # nyc test coverage 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # Bower dependency directory (https://bower.io/) 31 | bower_components 32 | 33 | # node-waf configuration 34 | .lock-wscript 35 | 36 | # Compiled binary addons (http://nodejs.org/api/addons.html) 37 | build/Release 38 | 39 | # Dependency directories 40 | node_modules/ 41 | jspm_packages/ 42 | 43 | # Typescript v1 declaration files 44 | typings/ 45 | 46 | # Optional npm cache directory 47 | .npm 48 | 49 | # Optional eslint cache 50 | .eslintcache 51 | 52 | # Optional REPL history 53 | .node_repl_history 54 | 55 | # Output of 'npm pack' 56 | *.tgz 57 | 58 | # Yarn Integrity file 59 | .yarn-integrity 60 | 61 | # dotenv environment variables file 62 | .env 63 | 64 | 65 | 66 | # End of https://www.gitignore.io/api/node -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 16 4 | branches: 5 | only: 6 | - master 7 | 8 | cache: 9 | yarn: true 10 | directories: 11 | - node_modules 12 | 13 | #after_success: npm run coverage 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | # [2.6.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.5.2...v2.6.0) (2023-11-23) 7 | 8 | 9 | ### Bug Fixes 10 | 11 | * bump consola dep to 3.x to align with other nuxt 2 packages ([#16](https://github.com/nuxt/friendly-errors-webpack-plugin/issues/16)) ([078d629](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/078d629)) 12 | * **doc:** update package name in readme sample ([#12](https://github.com/nuxt/friendly-errors-webpack-plugin/issues/12)) ([6cf5fbe](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/6cf5fbe)) 13 | 14 | 15 | 16 | 17 | ## [2.5.2](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.5.1...v2.5.2) (2021-10-14) 18 | 19 | 20 | 21 | 22 | ## [2.5.1](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.5.0...v2.5.1) (2021-04-09) 23 | 24 | 25 | 26 | 27 | # [2.5.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.0-beta.0...v2.5.0) (2019-05-20) 28 | 29 | 30 | 31 | 32 | # [2.4.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.2...v2.4.0) (2018-12-07) 33 | 34 | 35 | ### Features 36 | 37 | * display children errors and warnings ([812ffe4](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/812ffe4)) 38 | 39 | 40 | 41 | 42 | ## [2.3.2](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.1...v2.3.2) (2018-11-23) 43 | 44 | 45 | 46 | 47 | ## [2.3.1](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.0...v2.3.1) (2018-11-23) 48 | 49 | 50 | ### Bug Fixes 51 | 52 | * empty message in module not found error ([ac2c233](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ac2c233)) 53 | 54 | 55 | 56 | 57 | # [2.3.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.2.0...v2.3.0) (2018-11-03) 58 | 59 | 60 | 61 | 62 | # [2.2.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.1.0...v2.2.0) (2018-11-03) 63 | 64 | 65 | ### Bug Fixes 66 | 67 | * default value for options.logLevel ([1ac5b70](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/1ac5b70)) 68 | * ignore WAIT info with consola ([93964fa](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/93964fa)) 69 | * logLevel can be lower case value ([8db42c9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8db42c9)) 70 | * logLevel can be lower case value ([27d166b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/27d166b)) 71 | * message in windows ([ed4c84b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ed4c84b)) 72 | * remove duplicate SyntaxError ([8953760](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8953760)) 73 | 74 | 75 | ### Features 76 | 77 | * add consola reporter ([60e447c](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/60e447c)) 78 | * add reporter options ([7547af3](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/7547af3)) 79 | * add reporters ([ccddab5](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ccddab5)) 80 | * refactor reporter to standard logger ([00c979d](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/00c979d)) 81 | * skip branch build in pr ([25ca868](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/25ca868)) 82 | * **consola:** use tagged reporter ([e414613](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/e414613)) 83 | * **sandbox:** test with consola.wrapConsole ([8d98ae0](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8d98ae0)) 84 | 85 | 86 | 87 | 88 | # [2.1.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.2...v2.1.0) (2018-10-26) 89 | 90 | 91 | ### Features 92 | 93 | * sync with friendly-errors-webpack-plugin ([75c5c3b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/75c5c3b)) 94 | 95 | 96 | 97 | 98 | ## [2.0.2](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.1...v2.0.2) (2018-03-20) 99 | 100 | 101 | ### Features 102 | 103 | * clear console also according to log level ([655203d](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/655203d)) 104 | 105 | 106 | 107 | 108 | ## [2.0.1](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.0...v2.0.1) (2018-03-20) 109 | 110 | 111 | ### Bug Fixes 112 | 113 | * npm badge ([9bb4d3a](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/9bb4d3a)) 114 | 115 | 116 | ### Features 117 | 118 | * add log level ([ddcf45a](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ddcf45a)) 119 | 120 | 121 | 122 | 123 | # [2.0.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v1.6.1...v2.0.0) (2018-03-16) 124 | 125 | 126 | ### Bug Fixes 127 | 128 | * comma-dangle error ([2360434](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/2360434)) 129 | * lint script ([c3e88c9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/c3e88c9)) 130 | * move comma-dangle into rules ([9cd26c5](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/9cd26c5)) 131 | * test failures ([34ac16b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/34ac16b)) 132 | * windows eslint ([01f8059](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/01f8059)) 133 | 134 | 135 | ### Features 136 | 137 | * add release script ([bcd208f](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/bcd208f)) 138 | * upgrade to webpack4 ([458efe9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/458efe9)) 139 | * upgrade to webpack4 ([8927021](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8927021)) 140 | 141 | 142 | 143 | 144 | # [2.4.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.2...v2.4.0) (2018-12-07) 145 | 146 | 147 | ### Features 148 | 149 | * display children errors and warnings ([812ffe4](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/812ffe4)) 150 | 151 | 152 | 153 | 154 | ## [2.3.2](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.1...v2.3.2) (2018-11-23) 155 | 156 | 157 | 158 | 159 | ## [2.3.1](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.3.0...v2.3.1) (2018-11-23) 160 | 161 | 162 | ### Bug Fixes 163 | 164 | * empty message in module not found error ([ac2c233](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ac2c233)) 165 | 166 | 167 | 168 | 169 | # [2.3.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.2.0...v2.3.0) (2018-11-03) 170 | 171 | 172 | ### Bug Fixes 173 | 174 | * default value for options.logLevel ([1ac5b70](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/1ac5b70)) 175 | * ignore WAIT info with consola ([93964fa](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/93964fa)) 176 | 177 | 178 | ### Features 179 | 180 | * **consola:** use tagged reporter ([e414613](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/e414613)) 181 | * **sandbox:** test with consola.wrapConsole ([8d98ae0](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8d98ae0)) 182 | 183 | 184 | 185 | 186 | # [2.2.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.1.0...v2.2.0) (2018-11-03) 187 | 188 | 189 | ### Bug Fixes 190 | 191 | * logLevel can be lower case value ([8db42c9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8db42c9)) 192 | * logLevel can be lower case value ([27d166b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/27d166b)) 193 | * message in windows ([ed4c84b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ed4c84b)) 194 | * remove duplicate SyntaxError ([8953760](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8953760)) 195 | 196 | 197 | ### Features 198 | 199 | * add consola reporter ([60e447c](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/60e447c)) 200 | * add reporter options ([7547af3](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/7547af3)) 201 | * add reporters ([ccddab5](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ccddab5)) 202 | * refactor reporter to standard logger ([00c979d](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/00c979d)) 203 | * skip branch build in pr ([25ca868](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/25ca868)) 204 | 205 | 206 | 207 | 208 | # [2.1.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.2...v2.1.0) (2018-10-26) 209 | 210 | 211 | ### Features 212 | 213 | * sync with friendly-errors-webpack-plugin ([75c5c3b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/75c5c3b)) 214 | 215 | 216 | 217 | 218 | # 1.7.0 (2018-04-05) 219 | 220 | 221 | 222 | 223 | ## [2.0.2](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.1...v2.0.2) (2018-03-20) 224 | 225 | 226 | ### Features 227 | 228 | * clear console also according to log level ([655203d](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/655203d)) 229 | 230 | 231 | 232 | 233 | ## [2.0.1](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v2.0.0...v2.0.1) (2018-03-20) 234 | 235 | 236 | ### Bug Fixes 237 | 238 | * npm badge ([9bb4d3a](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/9bb4d3a)) 239 | 240 | 241 | ### Features 242 | 243 | * add log level ([ddcf45a](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/ddcf45a)) 244 | 245 | 246 | 247 | 248 | # [2.0.0](https://github.com/nuxt/friendly-errors-webpack-plugin/compare/v1.6.1...v2.0.0) (2018-03-16) 249 | 250 | 251 | ### Bug Fixes 252 | 253 | * comma-dangle error ([2360434](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/2360434)) 254 | * lint script ([c3e88c9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/c3e88c9)) 255 | * move comma-dangle into rules ([9cd26c5](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/9cd26c5)) 256 | * only transforms tests with babel. prevents [#35](https://github.com/nuxt/friendly-errors-webpack-plugin/issues/35) ([#41](https://github.com/nuxt/friendly-errors-webpack-plugin/issues/41)) ([c8c4f3e](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/c8c4f3e)) 257 | * test failures ([34ac16b](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/34ac16b)) 258 | * windows eslint ([01f8059](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/01f8059)) 259 | 260 | 261 | ### Features 262 | 263 | * add release script ([bcd208f](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/bcd208f)) 264 | * upgrade to webpack4 ([458efe9](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/458efe9)) 265 | * upgrade to webpack4 ([8927021](https://github.com/nuxt/friendly-errors-webpack-plugin/commit/8927021)) 266 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Geoffroy Warin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Friendly-errors-webpack-plugin 2 | 3 | [](https://www.npmjs.com/package/@nuxtjs/friendly-errors-webpack-plugin) 4 | [](https://travis-ci.org/nuxt/friendly-errors-webpack-plugin) 5 | [](https://ci.appveyor.com/project/nuxt/friendly-errors-webpack-plugin/branch/master) 6 | 7 | Friendly-errors-webpack-plugin recognizes certain classes of webpack 8 | errors and cleans, aggregates and prioritizes them to provide a better 9 | Developer Experience. 10 | 11 | It is easy to add types of errors so if you would like to see more 12 | errors get handled, please open a [PR](https://help.github.com/articles/creating-a-pull-request/)! 13 | 14 | ## Getting started 15 | 16 | ### Installation 17 | 18 | ```bash 19 | npm install @nuxt/friendly-errors-webpack-plugin --save-dev 20 | ``` 21 | 22 | ### Basic usage 23 | 24 | Simply add `FriendlyErrorsWebpackPlugin` to the plugin section in your Webpack config. 25 | 26 | ```javascript 27 | var FriendlyErrorsWebpackPlugin = require('@nuxt/friendly-errors-webpack-plugin'); 28 | 29 | var webpackConfig = { 30 | // ... 31 | plugins: [ 32 | new FriendlyErrorsWebpackPlugin(), 33 | ], 34 | // ... 35 | } 36 | ``` 37 | 38 | ### Turn off errors 39 | 40 | You need to turn off all error logging by setting your webpack config quiet option to true. 41 | 42 | ```javascript 43 | app.use(require('webpack-dev-middleware')(compiler, { 44 | // ... 45 | logLevel: 'SILENT', 46 | // ... 47 | })); 48 | ``` 49 | 50 | If you use the webpack-dev-server, there is a setting in webpack's ```devServer``` options: 51 | 52 | ```javascript 53 | // webpack config root 54 | { 55 | // ... 56 | devServer: { 57 | // ... 58 | quiet: true, 59 | // ... 60 | }, 61 | // ... 62 | } 63 | ``` 64 | 65 | If you use webpack-hot-middleware, that is done by setting the log option to `false`. You can do something sort of like this, depending upon your setup: 66 | 67 | ```javascript 68 | app.use(require('webpack-hot-middleware')(compiler, { 69 | log: false 70 | })); 71 | ``` 72 | 73 | _Thanks to [webpack-dashboard](https://github.com/FormidableLabs/webpack-dashboard) for this piece of info._ 74 | 75 | ## Demo 76 | 77 | ### Build success 78 | 79 |  80 | 81 | ### eslint-loader errors 82 | 83 |  84 | 85 | ### babel-loader syntax errors 86 | 87 |  88 | 89 | ### Module not found 90 | 91 |  92 | 93 | ## Options 94 | 95 | You can pass options to the plugin: 96 | 97 | ```js 98 | new FriendlyErrorsPlugin({ 99 | compilationSuccessInfo: { 100 | messages: ['You application is running here http://localhost:3000'], 101 | notes: ['Some additional notes to be displayed upon successful compilation'] 102 | }, 103 | onErrors: function (severity, errors) { 104 | // You can listen to errors transformed and prioritized by the plugin 105 | // severity can be 'error' or 'warn' 106 | }, 107 | // should the console be cleared between each compilation? 108 | // default is true 109 | clearConsole: true, 110 | 111 | // INFO: all logs 112 | // WARNING: warnings and errors 113 | // ERROR: only errors 114 | // SILENT: no log 115 | logLevel: true, 116 | 117 | // base: default 118 | // consola: consola adapter 119 | // can also be npm package name or reporter object 120 | reporter: 'consola' 121 | 122 | // add formatters and transformers (see below) 123 | additionalFormatters: [], 124 | additionalTransformers: [] 125 | }) 126 | ``` 127 | 128 | ## Adding desktop notifications 129 | 130 | The plugin has no native support for desktop notifications but it is easy 131 | to add them thanks to [node-notifier](https://www.npmjs.com/package/node-notifier) for instance. 132 | 133 | ```js 134 | var NotifierPlugin = require('@nuxt/friendly-errors-webpack-plugin'); 135 | var notifier = require('node-notifier'); 136 | var ICON = path.join(__dirname, 'icon.png'); 137 | 138 | new NotifierPlugin({ 139 | onErrors: (severity, errors) => { 140 | if (severity !== 'error') { 141 | return; 142 | } 143 | const error = errors[0]; 144 | notifier.notify({ 145 | title: "Webpack error", 146 | message: severity + ': ' + error.name, 147 | subtitle: error.file || '', 148 | icon: ICON 149 | }); 150 | } 151 | }) 152 | ] 153 | ``` 154 | 155 | ## API 156 | 157 | ### Transformers and formatters 158 | 159 | Webpack's errors processing, is done in four phases: 160 | 161 | 1. Extract relevant info from webpack errors. This is done by the plugin [here](https://github.com/nuxt/friendly-errors-webpack-plugin/blob/master/src/core/extractWebpackError.js) 162 | 2. Apply transformers to all errors to identify and annotate well know errors and give them a priority 163 | 3. Get only top priority error or top priority warnings if no errors are thrown 164 | 4. Apply formatters to all annotated errors 165 | 166 | You can add transformers and formatters. Please see [transformErrors](https://github.com/nuxt/friendly-errors-webpack-plugin/blob/master/src/core/transformErrors.js), 167 | and [formatErrors](https://github.com/nuxt/friendly-errors-webpack-plugin/blob/master/src/core/formatErrors.js) 168 | in the source code and take a look a the [default transformers](https://github.com/nuxt/friendly-errors-webpack-plugin/tree/master/src/transformers) 169 | and the [default formatters](https://github.com/nuxt/friendly-errors-webpack-plugin/tree/master/src/formatters). 170 | 171 | ### Customize Reporters 172 | 173 | Reporter is a class for generating output of errors messages, structure is: 174 | 175 | 1. Include following levels log methods: `success`, `info`, `note`, `warn`, `error`. 176 | 1. Include method `clearConsole` for clearing the terminal console. 177 | 178 | You can take a look at source code as example [base reporter](https://github.com/nuxt/friendly-errors-webpack-plugin/blob/master/src/reporters/base.js) 179 | -------------------------------------------------------------------------------- /_sandbox/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "babel-eslint", 4 | "env": { 5 | "browser": true, 6 | "commonjs": true, 7 | "es6": true, 8 | "jest": true, 9 | "node": true 10 | }, 11 | "parserOptions": { 12 | "ecmaVersion": 6, 13 | "sourceType": "module" 14 | }, 15 | "rules": { 16 | // http://eslint.org/docs/rules/ 17 | "no-unused-expressions": "warn", 18 | "no-unused-labels": "warn", 19 | "no-unused-vars": ["warn", { "vars": "local", "args": "none" }] 20 | } 21 | } -------------------------------------------------------------------------------- /_sandbox/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ -------------------------------------------------------------------------------- /_sandbox/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const unsed = 'I am unused'; 3 | 4 | export default class MyComponent extends React.Component { 5 | 6 | render() { 7 | return