How to use the umi-webpack-bundle-analyzer.BundleAnalyzerPlugin function in umi-webpack-bundle-analyzer

To help you get started, we’ve selected a few umi-webpack-bundle-analyzer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umijs / umi / packages / af-webpack / src / getWebpackConfig / index.js View on Github external
analyzerPort: process.env.ANALYZE_PORT || 8888,
          openAnalyzer: process.env.ANALYZE_OPEN !== 'none',
          // generate stats file while ANALYZE_DUMP exist
          generateStatsFile: !!process.env.ANALYZE_DUMP,
          statsFilename: process.env.ANALYZE_DUMP || 'stats.json',
          logLevel: process.env.ANALYZE_LOG_LEVEL || 'info',
          defaultSizes: 'parsed', // stat  // gzip
        },
      ]);
  }

  // plugins -> analyze report
  if (process.env.ANALYZE_REPORT) {
    webpackConfig
      .plugin('bundle-analyzer-reporter')
      .use(require('umi-webpack-bundle-analyzer').BundleAnalyzerPlugin, [
        {
          analyzerMode: 'disabled', // 关闭 analyzer server
          generateReportFile: true, // 开启报告生成功能
          reportDepth: 2, // 裁剪深度 2
          reportDir: process.cwd(),
          statsFilename: process.env.ANALYZE_DUMP || 'bundlestats.json', // 默认生成到 bundlestats.json
        },
      ]);
  }

  if (process.env.DUPLICATE_CHECKER) {
    webpackConfig
      .plugin('duplicate-package-checker')
      .use(require('duplicate-package-checker-webpack-plugin'));
  }

umi-webpack-bundle-analyzer

Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis