friendly-errors-webpack-plugin icon indicating copy to clipboard operation
friendly-errors-webpack-plugin copied to clipboard

No errors when webpack config fails

Open ThaNarie opened this issue 6 years ago • 2 comments

When your webpack config is invalid, it won't output to the console because quiet is true, but the plugin has not been 'applied'.

Error with quiet set to to false:

$ cross-env NODE_ENV=development webpack-dev-server --inline --progress --config build-tools/config/webpack/webpack.dev.conf.js
✖ 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.filename: A relative path is expected. However the provided value "/asset/[name].js" is an absolute path!
   -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.
   Please use output.path to specify absolute path and output.filename for the file name.
error Command failed with exit code 1.

Error with quiet set to true:

$ cross-env NODE_ENV=development webpack-dev-server --inline --progress --config build-tools/config/webpack/webpack.dev.conf.js
error Command failed with exit code 1.

Adding a log in the constructor and in the apply(compiler) { methods, only the constructor is executed.

So it seems there is a 'gap' before the plugin kicks in, where errors could happen, but don't get outputted because quiet needs to be set to true for this plugin to 'work'.

I'm not sure if there is a way to fix this, otherwise it would be good to clearly mention it in the readme/docs; when webpack exits without an error, temporarily disable the quiet mode.

ThaNarie avatar Jun 22 '18 09:06 ThaNarie

I believe this will be fixed with https://github.com/geowarin/friendly-errors-webpack-plugin/pull/66 as that change will watch on the "failed" hook. This means webpack failures will be caught in addition to the compilation errors.

pk-nb avatar Jul 17 '18 16:07 pk-nb

Unfortunately I think that will not be the case :(

Adding a log in the constructor and in the apply(compiler) methods, only the constructor is executed.

The "failed" hook is added in the apply method, which is never executed in the described case.

ThaNarie avatar Jul 17 '18 17:07 ThaNarie