polymer - 如何将 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?
解决方案
polymer.json 只是聚合物构建的配置。Github Pages 不会为您下载或托管任何内容,除非您的 repo 中的内容。因此,您需要从诸如https://cdnjs.com之类的 CDN 加载任何不在您的 repo(npm 依赖项)中的内容。
推荐阅读
- ios - libGDX iOS主页按钮杀死游戏
- vue.js - vue-form-generator github repo 声明它支持“自定义样式”。文档在哪里?
- php - 如何将消息从另一台服务器“传递”到 php 脚本?
- r - 从 cut() 的间隔中提取值
- java - 从 MySQL 数据库中存储和检索盐
- php - Htaccess 重写以删除不适用于目录的 .php 扩展名
- java - JsonMappingException:无限递归
- linked-list - 在链表中包含头节点和尾节点有什么好处?
- debugging - 如何在 CLion 中将所有行设置为断点?
- python - Python super() can't call parent's inherited method