如何在 Ubuntu 18.10 服务器上部署使用 ParcelJS 构建的 Web 应用程序?
How do I deploy my web app built with ParcelJS on my Ubuntu 18.10 server?
我有一个 HTML 网页,其中使用了一些 CSS 和 TypeScript。我一直在使用 ParcelJS 开发服务器来构建和测试我的页面。
现在我想通过 Web 服务器提供我的应用程序。我有一台设置了 nginx 的 Ubuntu 18.10 DigitalOcean droplet/virtual 机器。
我将我的代码克隆到我的服务器上,安装了 ParcelJS,然后 运行 parcel build index.html
按照说明 here。
然后我尝试通过创建从 /var/www/mysitedomain/html/app.html
到 ~/myappdir/dist/index.html
的符号链接来部署我的网页。
这(有点)有效:当我访问我的网站时,我的浏览器会加载我的 index.html。
但是我的CSS的none正在渲染,我的脚本也好像不是运行!
很明显,我做错了什么。我应该怎么做才能部署我的应用程序?
这是我的删节 index.html(在 运行 parcel build index.html
之后):
<!DOCTYPE html>
<head>
<title>Nothing to see here!</title>
<link rel="stylesheet" href="/sidebar.04cc1813.css">
</head>
<body>
<aside class="sidenav">
<h1>A sidebar</h1>
</aside>
<section class="main">
<p>Welcome to the semantic web!</p>
</section>
<script src="/main.9b45144c.js"></script>
</body>
这是我的 /etc/nginx/sites-enabled/mysite.com
:
server {
listen 80;
listen [::]:80;
root /var/www/mysite.com/html;
index index.html index.htm index.nginx-debian.html app.html;
server_name mysite.com www.mysite.com;
location / {
try_files $uri $uri/ =404;
}
}
将 --public-url ./
CLI arg 添加到您的 parcel 命令将告诉 parcel 发出相对于给定基础 url 的资产 URL 引用。 IE。您现有的:
<script src="/main.9b45144c.js"></script>
会变成:
<script src="./main.9b45144c.js"></script>
与 CSS 和其他资产相同...
另见:https://parceljs.org/cli.html#set-the-public-url-to-serve-on
我有一个 HTML 网页,其中使用了一些 CSS 和 TypeScript。我一直在使用 ParcelJS 开发服务器来构建和测试我的页面。
现在我想通过 Web 服务器提供我的应用程序。我有一台设置了 nginx 的 Ubuntu 18.10 DigitalOcean droplet/virtual 机器。
我将我的代码克隆到我的服务器上,安装了 ParcelJS,然后 运行 parcel build index.html
按照说明 here。
然后我尝试通过创建从 /var/www/mysitedomain/html/app.html
到 ~/myappdir/dist/index.html
的符号链接来部署我的网页。
这(有点)有效:当我访问我的网站时,我的浏览器会加载我的 index.html。
但是我的CSS的none正在渲染,我的脚本也好像不是运行!
很明显,我做错了什么。我应该怎么做才能部署我的应用程序?
这是我的删节 index.html(在 运行 parcel build index.html
之后):
<!DOCTYPE html>
<head>
<title>Nothing to see here!</title>
<link rel="stylesheet" href="/sidebar.04cc1813.css">
</head>
<body>
<aside class="sidenav">
<h1>A sidebar</h1>
</aside>
<section class="main">
<p>Welcome to the semantic web!</p>
</section>
<script src="/main.9b45144c.js"></script>
</body>
这是我的 /etc/nginx/sites-enabled/mysite.com
:
server {
listen 80;
listen [::]:80;
root /var/www/mysite.com/html;
index index.html index.htm index.nginx-debian.html app.html;
server_name mysite.com www.mysite.com;
location / {
try_files $uri $uri/ =404;
}
}
将 --public-url ./
CLI arg 添加到您的 parcel 命令将告诉 parcel 发出相对于给定基础 url 的资产 URL 引用。 IE。您现有的:
<script src="/main.9b45144c.js"></script>
会变成:
<script src="./main.9b45144c.js"></script>
与 CSS 和其他资产相同...
另见:https://parceljs.org/cli.html#set-the-public-url-to-serve-on