如何配置Polymer构建,以便将构建在Windows上的应用程序部署到运行NGINX的Raspberry Pi(在子目录中)?
我无法安装
polymer-cli
直接在我的覆盆子皮上
chromedriver
聚合物cli
(需要)仅适用于64位Linux,官方的Raspian OS目前仅为32位。
所以我在我的Windows机器上安装了polymer cli,并根据
https://www.polymer-project.org/3.0/start/toolbox/set-up
,我还创建了新的查看页面。
我现在可以使用
polymer serve
(在Windows计算机的浏览器中正确显示应用程序)并使用
polymer build
.现在我要部署,所以我复制了
build
目录(其中包含三个内置变量,
es5-bundled
es6-bundled
和
esm-bundled
)到NGINX根目录的子目录,
/var/www/html/polymer/build
.
启动我的浏览器并指向
http://<raspberrypi-ip>/polymer/build/esm-build
我看到两个错误。
这个
src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"
和
src="src/my-app.js"
在里面
index.html
给404。我找不到如何配置polymer cli来更改这些,并且仍然在Windows中提供一个可用的应用程序,所以我手动添加了
polymer/default/
这两条路在
指数html
.
现在我的浏览器中出现了一个灰色页面,没有进一步的错误消息。。。
移动到我的手机浏览器并输入相同的url,
http://<raspberrypi-ip>/polymer/esm-build
,我实际上看到了我的应用程序以及
Oops you hit a 404. Head back to home
链接通过这个链接,我进入了我的应用程序,它似乎在工作——但URL现在是
http://<raspberrypi-ip>/new-view
我也玩过NGINX
try_files
没有运气。。。
server {
...
location /polymer/default {
try_files $uri /polymer/default/index.html =404;
}
}
编辑:在
Serving Polymer App to a /path not at root
我发现我也需要调整
rootPath
在索引中。html。但是,如果我将浏览器指向
http://<raspberrypi-ip>/polymer/esm-build/index.html
...
还有,有没有办法参考
根路径
在
<script src="">
这是我第一次接触Polymer和NGINX,因此非常感谢您的指点。