generator-spfx icon indicating copy to clipboard operation
generator-spfx copied to clipboard

Webpack Bundle Analyzer config on gulp.js

Open joelfmrodrigues opened this issue 4 years ago • 4 comments

General Information

  • [ ] Usage
  • [x] Development
  • [ ] Documentation
  • [ ] Feature Request

Specific generator

  • [x] Addons
  • [ ] HandlebarsJS

What Version you are running?

  • NodeJS: v10.20.1
  • NPM:6.14.8
  • @pnp/spfx: 1.15.0

Describe your problem

Hi, I had previously integrated spfx-fast-serve with the generator (on my fork) and all seemed to work well. I have now pulled the latest changes from this repo and things no longer work as there is an "if" that restricts when the webpack merge config is executed (image below). If I comment the "if" condition, all works as expected.

What exactly is the condition doing and is there a simple way I could get around this?

Thanks :)

Branch: https://github.com/joelfmrodrigues/generator-spfx/tree/add-spfx-fast-serve

image

joelfmrodrigues avatar Sep 03 '20 22:09 joelfmrodrigues

Webpack Bundle analyser drain nowadays a lot of the performance and is not executed during run-time of gulp serve anymore. That's why this piece of configuration only gets merged and executed on gulp dist, gulp dev and when started with gulp serve --analyze.

In general, this should not be an issue. You can even run mergeConfig multiple times. However, there is currently no support for 'spfx-fast-serve' in this generator.

StfBauer avatar Sep 04 '20 07:09 StfBauer

Thanks @StfBauer

Splitting into two separate mergeConfig does seem to resolve the problem :) We use spfx-fast-serve internally on pretty much all SPFx projects, hence adding it to the generator. Would you consider a PR?

joelfmrodrigues avatar Sep 04 '20 08:09 joelfmrodrigues

When there is a PR then it is something to consider.

StfBauer avatar Sep 04 '20 13:09 StfBauer

Thanks. Will aks Sergei Sergeev if he is ok with the tool being added here and submit a PR if so. On a side note, at the moment I am assuming that the user has spfx-fast-serve globally installed. Is this acceptable, or should it be added as a dev dependency?

joelfmrodrigues avatar Sep 04 '20 14:09 joelfmrodrigues