How to use umi-webpack-bundle-analyzer - 2 common examples

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'));
  }
github umijs / umi / packages / umi-ui-tasks / src / server / util / stats.ts View on Github external
export function parseChartData(stats) {
  if (!stats) {
    return null;
  }
  let chartData;
  const analyzer = require('umi-webpack-bundle-analyzer/lib/analyzer');

  try {
    /**
     * outputPath:
     *  1. build: stats.outputPath
     *  2. dev: null
     */
    chartData = analyzer.getViewerData(stats, stats.outputPath, {
      excludeAssets: null,
    });
  } catch (err) {
    chartData = null;
  }

  if (isPlainObject(chartData) && isEmpty(chartData)) {
    chartData = null;
  }

  return chartData;
}

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