Step 1. Install webpack-stats-plugin

npm install --save-dev webpack-stats-plugin

or

yarn add --dev webpack-stats-plugin

Step 2. Configure

// next.config.js
const { StatsWriterPlugin } = require('webpack-stats-plugin')

module.exports = {
  webpack: (config, {}) => {
    config.plugins.push(
      new StatsWriterPlugin(
        filename: 'stats.json',
        stats: {
          context: './src', // optional, will improve readability of the paths
          assets: true,
          entrypoints: true,
          chunks: true,
          modules: true
        }
      )
    );

    return config;
  }
};



Need help?Contact us via email, Twitter, or Github!