3

I have an existing sharepoint framework (SPFX) project. Now I want to create a custom search web part. So how can I add a new webaprt to existing solution

PS: I am very new to SPFx. TIA

1 Answer 1

7

Open the existing directory structure containing spfx in the command prompt.

After that simply call the yeoman generator again, fill up the details like webpart name, desc etc and it will automatically detect, handle and add the new webpart to the existing solution.

yo @microsoft/sharepoint

Run this in the command prompt.

For example below, I first created a webpart (helloworld) in E:\test-spfx folder. After that i ran the generator again and created another webpart hello2 in the same folder, it will add the webpart named hello2 in the same solution.

enter image description here

enter image description here

2
  • Nice! But is it possible to combine already existing webparts in one solutions....so basically if I have webaprt_a and webpart_b can I move webpart_b into webpart_a?
    – JohnRambo
    Commented Jan 11, 2021 at 11:07
  • 1
    @JohnRambo: if the SPFX version are aligned (if not upgrade the older WP to the same version of the newer), you can : 1. copy the webpart sources (./src/webparts/webpart_a), 2. Update the "manifest" (./config/config.json) to include both webparts.
    – Steve B
    Commented Nov 26, 2021 at 9:33

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.