Sp-dev-docs: Bundles stats not generated when running `$ gulp bundle`

Created on 16 Oct 2017  路  5Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

Bundle stats written to disk after running $ gulp bundle.

Observed Behavior

Bundle stats are not written to disk.

Steps to Reproduce

  • build new project using the v1.3.2 generator
  • choose online as the platform
  • run $ gulp bundle
  • bundle stats are not written to disk

Most helpful comment

@waldekmastykarz check https://www.npmjs.com/package/source-map-explorer ... I prefer this than the bloated one that was included before.

All 5 comments

Same here, any news?

The Webpack plugin that was generating the stats was removed because of a license issue, but you're free to add it back yourself.

To add it back, install the webpack-bundle-analyzer package in your project (npm install webpack-bundle-analyzer --save-dev) and include this snippet in your gulpfile.js:

'use strict';

const gulp = require('gulp');
const path = require('path');
const build = require('@microsoft/sp-build-web');
const bundleAnalyzer = require('webpack-bundle-analyzer');

build.configureWebpack.mergeConfig({
  additionalConfiguration: (generatedConfiguration) => {
    const lastDirName = path.basename(__dirname);
    const dropPath = path.join(__dirname, 'temp', 'stats');
    generatedConfiguration.plugins.push(new bundleAnalyzer.BundleAnalyzerPlugin({
      openAnalyzer: false,
      analyzerMode: 'static',
      reportFilename: path.join(dropPath, `${lastDirName}.stats.html`),
      generateStatsFile: true,
      statsFilename: path.join(dropPath, `${lastDirName}.stats.json`),
      logLevel: 'error'
    }));

    return generatedConfiguration;
  }
});

build.initialize(gulp);

You can find more information on extending the webpack configuration here.

I believe @chakkaradeep was going to write an article about how to do this specifically.

Thanks for clarification @iclanton. It would be helpful if this was communicated with the release of the generator.

@waldekmastykarz check https://www.npmjs.com/package/source-map-explorer ... I prefer this than the bloated one that was included before.

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

Was this page helpful?
0 / 5 - 0 ratings