1

I am using webpack-bundle-analyzer library for my VUE application. I had written following code snippet in my vue.config.js.

I passed openAnalyzer option as false to not open report in the default browser. Not sure why it's not working. Even when I mention it as false still report is getting opening in the default browser.

plugins: [
      new BundleAnalyzerPlugin({
        analyzerMode: 'static',
        openAnalyzer: false,
      }),
    ],

can anyone help me on this. I am using web-pack4

Thanks

subbu
  • 562
  • 3
  • 8
  • 21

1 Answers1

1

Use analyzerMode: "disabled" instead. Dirty but fixes the problem, if for example you wanted to run this only when building for production:

const WebpackBundleAnalyzer = require("webpack-bundle-analyzer")
  .BundleAnalyzerPlugin;
const AnalyzerMode = function() {
  return process.env.NODE_ENV === "production" ? "static" : "disabled";
};

// other config stuff

new WebpackBundleAnalyzer({
    // openAnalyzer: false, // line useless since it's broken
    analyzerMode: AnalyzerMode(), //static, disabled, server
    reportFilename: "BundleAnalyzerReport.html"
  })

Then pass an env mode switch when starting serve/build (if it's not done automatically for you) like so:

vue-cli-service serve --mode development
vue-cli-service build --mode production
Zir
  • 63
  • 7