包装 SPFx 样品
Posted
技术标签:
【中文标题】包装 SPFx 样品【英文标题】:Packaging SPFx Samples 【发布时间】:2020-05-28 12:20:55 【问题描述】:我正在尝试从 GitHub https://github.com/SharePoint/sp-dev-fx-webparts 打包一些 SharePoint webparts
文档库https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-documents-detailslist
目标是从 SharePoint 中的不同网站集中引入文档库
安全网格https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-securitygrid
安全网格将允许我的团队快速访问以控制谁可以访问各种站点库中的哪些文件。
我正在使用 VS Code、NVM、NPM 和 Gulp。文档库 Webpart 是 SPFx GA (1.0)。使用 nvm 我将 node 设置为安装 v6.17.1,结果如下
added 1691 packages from 1741 contributors and audited 111373 packages in 323.901s
found 884 vulnerabilities (295 low, 34 moderate, 548 high, 7 critical)
run `npm audit fix` to fix them, or `npm audit` for details
之后我运行“gulp clean & gulp bundle --ship & gulp package-solution --ship”没有问题。
我将包部署到我的 O365 租户,但在尝试将其添加到 SharePoint 页面时不断收到此错误。
Something went wrong
If the problem persists, contact the site administrator and give them the information in Technical Details.
Technical Details
[SPLoaderError.loadComponentError]:
***Failed to load component "8635c52e-cf0b-4c6d-a5ba-66f1d8d92005" (LibraryDocumentsWebPart). Original error: ***Failed to load URL '/sites/dev03/Style Library/CDN/react-documents-detailslist-librarydocumentswebpartstrings_en-us_f6b12acaf67a67cf5971e8da720715f9.js' for resource 'LibraryDocumentsWebPartStrings' in component '8635c52e-cf0b-4c6d-a5ba-66f1d8d92005' (LibraryDocumentsWebPart). The file was not found in the server.
***INNERERROR:
***Failed to load URL '/sites/dev03/Style Library/CDN/react-documents-detailslist-librarydocumentswebpartstrings_en-us_f6b12acaf67a67cf5971e8da720715f9.js' for resource 'LibraryDocumentsWebPartStrings' in component '8635c52e-cf0b-4c6d-a5ba-66f1d8d92005' (LibraryDocumentsWebPart). The file was not found in the server.
***CALLSTACK:
Error
at t (https://spoprod-a.akamaihd.net/files/sp-client/sp-loader-assembly_en-us_3993179394b3b04563388c5043768f22.js:3:53337)
at t (https://spoprod-a.akamaihd.net/files/sp-client/sp-loader-assembly_en-us_3993179394b3b04563388c5043768f22.js:1:139106)
at e.buildErrorWithVerboseLog (https://spoprod-a.akamaihd.net/files/sp-client/sp-loader-assembly_en-us_3993179394b3b04563388c5043768f22.js:1:149068)
at e.buildLoadComponentError (https://spoprod-a.akamaihd.net/files/sp-client/sp-loader-assembly_en-us_3993179394b3b04563388c5043768f22.js:1:145093)
at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client/sp-loader-assembly_en-us_3993179394b3b04563388c5043768f22.js:1:135256)
对新程序员有什么帮助吗?
【问题讨论】:
我假设您已经检查过文件 '/sites/dev03/Style Library/CDN/react-documents-detailslist-librarydocumentswebpartstrings_en-us_f6b12acaf67a67cf5971e8da720715f9.js' 是否确实存在? 不是。我还检查了安装 Web 部件的站点的样式库includeClientSideAssets
属性?此外,查看构建 .sppkg 文件的 sharepoint 文件夹下的调试文件夹,以查看包中包含哪些文件。
它没有。我找到了这个link,现在将includeClientSideAssets: true
添加到package-solution.json 中,现在得到这个错误Additional properties not allowed: includeClientSideAssets
您使用的是哪个版本的 SharePoint 框架?
【参考方案1】:
直到 SharePoint 框架 1.4 版才添加对在包中包含客户端资产的支持。在此之前,您需要手动部署这些附加资产。请参阅描述类似问题的 this thread,以及有关如何更新框架的 official doc。
【讨论】:
如果这个答案有帮助,请务必mark it as such以上是关于包装 SPFx 样品的主要内容,如果未能解决你的问题,请参考以下文章