I can create package of react app for SharePoint online by using "gulp serve" and "gulp package-solution" commands. However, I want to create package by using Webpack. How can I achieve this?

  • Why do you need it? Normally you shouldn't use webpack directly in SPFx, everything is handled by SPFx build pipeline internally. Dec 17, 2018 at 7:21
  • To implement tree shaking and features of webpack.. Dec 17, 2018 at 7:34

1 Answer 1


You can't create an SPFx package using webpack directly, however you have options to modify webpack configuration which is used by SPFx build pipeline internally.

Good reading here - Extending Webpack in the SharePoint Framework toolchain.
So theoretically you are able to modify some settings inside a webpack pipeline.
However, consider a few gotchas:

  • SPFx still uses webpack 3, thus you should use tree shaking features of webpack 3 (which are probably don't work as good as in 4.x version)

  • I'm not sure if in general, it's a good idea to change production-related settings for SPFx. From my perspective, it might lead to unexpected errors. Unfortunately, Microsoft doesn't provide clear information on this topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.