首页 > 解决方案 > 如何将 Polymer3 应用程序部署到 GH Pages?

问题描述

我使用 Polymer CLI 创建了一个 polymer3 应用程序。我似乎无法正确配置 polymer.json 文件,以便当我部署到 GH 页面时一切都正确加载。

目前我的 polymer.json 看起来像这样:

{
"entrypoint": "index.html",
  "shell": "src/site-app/site-app.js",
  "sources": [
    "src/site-app/**",
    "package.json",
    "css/**",
    "js/**"
  ],
  "extraDependencies": [
    "manifest.json",
    "node_modules/@webcomponents/**",
    "node_modules/@polymer/**",
    "node_modules/@fabricelements/**",
    "node_modules/web-animations-js/**"
  ],
  "moduleResolution": "node",
  "npm": true,
  "lint": {
    "rules": [
      "polymer-3"
    ]
  },
  "builds": [{
    "preset": "es6-unbundled"
  }]
}

我在 Chrome 上的开发控制台中看到的错误如下 </p>

web-animations-next-lite.min.js:1 Failed to load resource: the server responded with a status of 404 ()
web-animations.min.js:1 Failed to load resource: the server responded with a status of 404 ()
webcomponents-loader.js:1 Failed to load resource: the server responded with a status of 404 ()
8
website.github.io/:1 Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".

如何修复我的 polymer.json 以便正确部署到 GH Pages?

标签: polymergithub-pagespolymer-3.x

解决方案


polymer.json 只是聚合物构建的配置。Github Pages 不会为您下载或托管任何内容,除非您的 repo 中的内容。因此,您需要从诸如https://cdnjs.com之类的 CDN 加载任何不在您的 repo(npm 依赖项)中的内容。


推荐阅读