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. – Sergei Sergeev Dec 17 '18 at 7:21
  • To implement tree shaking and features of webpack.. – RajeshSharepointGeek Dec 17 '18 at 7:34

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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