0

当我尝试在 sharepoint 中部署包时,它每次引用 localhost 资源

有人可以让我知道我可以从哪里更改此配置,以便它应该从 CDN 路径而不是 localhost 引用

下面是我的 package-solution.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
  "solution": {
    "name": "mega-menu-sp-fx-client-side-solution",
    "id": "8f49d75c-5a49-4657-b81b-0290f239350f",
    "version": "10.0.0.0",
    "includeClientSideAssets": true,
    "skipFeatureDeployment": true,
    "isDomainIsolated": false,
    "features": [
      {
        "title": "Application Extension - Deployment of custom action.",
        "description": "Deploys a custom action with ClientSideComponentId association",
        "id": "0d2345df-2a49-4ce9-ba2d-bee7ad3e7a02",
        "version": "10.0.0.0",
        "assets": {
          "elementManifests": [
            "elements.xml",
            "clientsideinstance.xml"
          ]
        }
      }
    ]
  },
  "paths": {
    "zippedPackage": "solution/mega-menu-sp-fx.sppkg"
  }
}

下面是我的 write-manifest.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
  "cdnBasePath": "https://Mytenant.sharepoint.com/sites/MyTechTheme/MenuFiles"
}
4

2 回答 2

0

我试图找出问题所在。对于发布而不是 gulp package-solution --ship 我使用了 gulp package-solution 所以除非并且直到我们不提及 --ship 它不会引用 CDN

因此,为了在 SPO 中部署包,我们需要使用 gulp bundle --ship 和 gulp package-solution --ship

于 2019-11-13T05:50:06.900 回答
0

要从 CDN 或 SharePoint 库加载 SPFx 资产,请将'includeClientSideAsserts'值设置为 false。

在此处输入图像描述

下面的线程显示从库中加载资产供您参考。

https://www.c-sharpcorner.com/article/sharepoint-framework-deploy-spfx-webparts-to-sharepoint-library/

于 2019-11-12T08:00:56.213 回答