Currently you can only have one web part per project becaue all the required files are provisioned during the project creation.
In addition it would be nice if you will be able to add an additional web part the easy way similar to VS.
Let's say you have a gulp task like this.
gulp add-webpart
Web part name: HelloWorld2
Web part description: Additional Hello World Web Part
After that the gulp task can stream and copy the files, rename them and add it to the source folder. Should be a pretty easy but convenient addition.
I know It's just a developer preview but I thing it would be pretty useful.
So, we have a bug in our localization pipeline that blocks this today. In general, you can run the yo command multiple times and you will get multiple controls that will get bundled into a single package.
Oh great!!! Most Yeoman generators are just one timer, that's why I haven't tried this option yet.
Thanks for the update.
Just don't do it yet :)
To slow. Tried it already. ;) Now I see the problem.
Here is more for you to play with:
yo @microsoft/sharepoint
yo @microsoft/sharepoint:webpart
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" react --component-description=”some text here”
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" none
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" knockout
yo @microsoft/sharepoint "contoso-pjct" webpart
yo @microsoft/sharepoint "contoso-pjct"
I think @iclanton was fixing this, so assigning the bug to him.
I've added a new webpart to the project and got these error
C:\Users\Mauricio Nunes dos R\Documents\Git\sharepoint-components-hello-world
λ yo @microsoft/sharepoint
_-----_
| | .--------------------------.
|--(o)--| | Welcome to the |
`---------´ | SharePoint Client-side |
( _´U`_ ) | Solution Generator |
/___A___\ '--------------------------'
| ~ |
__'.___.'__
´ ` |° ´ Y `
Add new webpart to solution sharepoint-components-hello-world.
? What is your webpart name? hello-universe
? What is your webpart description? hello-universe description
create src\webparts\helloUniverse\loc\en-us.js
create src\webparts\helloUniverse\loc\mystrings.d.ts
create src\webparts\helloUniverse\tests\HelloUniverse.test.ts
create src\webparts\helloUniverse\IHelloUniverseWebPartProps.ts
create src\webparts\helloUniverse\HelloUniverse.module.scss
create src\webparts\helloUniverse\HelloUniverseWebPart.manifest.json
create src\webparts\helloUniverse\components\HelloUniverse.tsx
create src\webparts\helloUniverse\HelloUniverseWebPart.ts
force config\config.json
_=+#####!
###########| .----------------------------------------------------------.
###/ (##|(@) | Congratulations! |
### ######| \ | Solution sharepoint-components-hello-world is created. |
###/ /###| (@) | Run gulp serve to play with it! |
####### ##| / '----------------------------------------------------------'
### /##|(@)
###########|
**=+####!
C:\Users\Mauricio Nunes dos R\Documents\Git\sharepoint-components-hello-world
λ gulp serve
Build target: DEBUG
[15:15:13] Using gulpfile ~\Documents\Git\sharepoint-components-hello-world\gulpfile.js
[15:15:13] Starting gulp
[15:15:13] Starting 'serve'...
[15:15:13] Starting subtask 'pre-copy'...
[15:15:13] Finished subtask 'pre-copy' after 19 ms
[15:15:13] Starting subtask 'tslint'...
[15:15:13] Starting subtask 'copyStaticAssets'...
[15:15:13] Starting subtask 'text'...
[15:15:13] Starting subtask 'sass'...
[15:15:17] Finished subtask 'text' after 3.28 s
[15:15:17] Finished subtask 'sass' after 3.26 s
[15:15:17] Starting subtask 'typescript'...
[15:15:18] Finished subtask 'copyStaticAssets' after 4.58 s
[15:15:23] Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(2,3): error TS2300: Duplicate identifier 'PropertyPaneDescription'.
[15:15:23] Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(3,3): error TS2300: Duplicate identifier 'BasicGroupName'.
[15:15:23] Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(4,3): error TS2300: Duplicate identifier 'DescriptionFieldLabel'.
[15:15:23] Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(9,3): error TS2300: Duplicate identifier 'export='.
[15:15:23] Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(2,3): error TS2300: Duplicate identifier 'PropertyPaneDescription'.
[15:15:23] Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(3,3): error TS2300: Duplicate identifier 'BasicGroupName'.
[15:15:23] Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(4,3): error TS2300: Duplicate identifier 'DescriptionFieldLabel'.
[15:15:23] Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(9,3): error TS2300: Duplicate identifier 'export='.
[15:15:23] Finished subtask 'tslint' after 9.44 s
[15:15:23] Error - 'typescript' sub task errored after 6.08 s
"TypeScript error(s) occurred."
[15:15:23] 'serve' errored after 9.54 s
[15:15:23]
[15:15:23] ==================[ Finished ]==================
Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(2,3): error TS2300: Duplicate identifier 'PropertyPaneDescription'.
Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(3,3): error TS2300: Duplicate identifier 'BasicGroupName'.
Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(4,3): error TS2300: Duplicate identifier 'DescriptionFieldLabel'.
Error - typescript - src\webparts\firstComponent\loc\mystrings.d.ts(9,3): error TS2300: Duplicate identifier 'export='.
Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(2,3): error TS2300: Duplicate identifier 'PropertyPaneDescription'.
Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(3,3): error TS2300: Duplicate identifier 'BasicGroupName'.
Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(4,3): error TS2300: Duplicate identifier 'DescriptionFieldLabel'.
Error - typescript - src\webparts\helloUniverse\loc\mystrings.d.ts(9,3): error TS2300: Duplicate identifier 'export='.
Error - 'typescript' sub task errored after 6.08 s
"TypeScript error(s) occurred."
[15:15:24] Project sharepoint-components-hello-world version: 0.0.1
[15:15:24] Build tools version: 0.7.1
[15:15:24] Node version: v5.6.0
[15:15:24] Total duration: 19 s
[15:15:24] Task errors: 9
@mauricionr - yup, don't do that yet. See my comments towards the beginning of the thread. I should have been more explicit / clear in my statements.
@patmill i saw, i've just did this to test the framework :smile:
Thanks!
OK, sorted this out a bit. @evfirs - the issue has to do with how the generator is creating the strings.
In the meantime, here's how to work around this.
1 - Go to your project, find your newly added webpart, and go to the loc folder
2 - open mystrings.d.ts and change the interface and module values, and update the strings in the module to point at your interface. So something like this:
declare interface IMyNewWebPartStrings{
...
}
declare module 'mynewwebpartstrings' {
const strings : IMyNewWebPartStrings;
export = strings;
}
3 - update your webpart.ts file to have
import * as strings from 'mynewwebpartstrings';
4 - update config.json to use the updated module. So something like
"mynewwebpartstrings": "webparts/newwebpart/loc/{locale}.js"
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues
Most helpful comment
Here is more for you to play with:
yo @microsoft/sharepoint
yo @microsoft/sharepoint:webpart
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" react --component-description=”some text here”
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" none
yo @microsoft/sharepoint "contoso-pjct" webpart "contoso-webpart" knockout
yo @microsoft/sharepoint "contoso-pjct" webpart
yo @microsoft/sharepoint "contoso-pjct"