A Webpack plugin to export errors and warnings to JSON files.
When there are too many errors, the console screen becomes hard to read and truncates some of the error messages. This plugin addresses this issue by generating separate JSON files for errors and warnings in the project's root directory.
Install the plugin via npm:
npm install webpack-error2json
To use the plugin in your Webpack configuration, follow these steps:
Integrate the Plugin with Webpack: In your webpack.config.js file, require the plugin and add it to the plugins array.
const path = require('path');
const ErrorToJsonPlugin = require('webpack-error2json');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new ErrorToJsonPlugin()
],
mode: 'development'
};
and and just build from webpack.
npx webpack --config webpack.config.js
The plugin generates the following files in the root directory:
webpack-errors.json
webpack-warnings.json
[
{
"message": "Module not found: Error: Can't resolve '@/bower_components/jquery_legacy/dist/blabla' in 'C:\\Users\\cengiz.ilhan\\source\\repos\\Assets\\webpack-project\\Static\\src...'",
"details": "resolve '@/bower_components/jquery_legacy/dist/blabla' in 'C:\\Users\\cengiz.ilhan\\source\\repos\\..."
},
{
"message": "Module not found: Error: Can't resolve '@/bower_components/jquery_legacy/dist/blabla' in 'C:\\Users\\cengiz.ilhan\\source\\repos\\Assets\\webpack-project\\Static\\src...'",
"details": "resolve '@/bower_components/jquery_legacy/dist/blabla' in 'C:\\Users\\cengiz.ilhan\\source\\repos\\..."
}
]