Learn from experience & rename output JS

This commit is contained in:
Emi Simpson 2022-11-13 00:23:46 -05:00
parent bb9bfc1346
commit 8c5e4591a6
Signed by: Emi
GPG Key ID: A12F2C2FFDC3D847
4 changed files with 25 additions and 17 deletions

View File

@ -39,7 +39,7 @@ lebab --replace output/ --transform arrow,arrow-return
spago bundle-app --minify spago bundle-app --minify
# Perform some final optimizations # Perform some final optimizations
uglifyjs --compress --mangle --toplevel --mangle-props -- index.js > index.js uglifyjs --compress --mangle --toplevel -- index.js > aviary.min.js
``` ```
Aside: If you know a way to bring the file size down further, *please* open an issue! Aside: If you know a way to bring the file size down further, *please* open an issue!
@ -52,8 +52,9 @@ Aviary works with a [`0x0`]-compatible server as a backend. To set up a quick
server for development, follow these steps: server for development, follow these steps:
**Prerequisites:** **Prerequisites:**
- Python, `pip`, and `venv` - Python3 with `pip`
- `git` - `git`
- A C++ compiler (e.g. `gcc`) & libc/python development headers
```bash ```bash
# Download 0x0 # Download 0x0
@ -61,8 +62,9 @@ git clone https://git.0x0.st/mia/0x0
cd 0x0 cd 0x0
# Set up the environment and install deps # Set up the environment and install deps
python -m venv venv --prompt 0x0 python3 -m venv venv --prompt 0x0
source venv/bin/activate.sh || source venv/bin/activate.fish source venv/bin/activate || source venv/bin/activate.fish
pip install wheel
pip install -r requirements.txt pip install -r requirements.txt
pip install gunicorn pip install gunicorn
@ -72,10 +74,6 @@ echo "
# Use a local sqlite3 database to store information # Use a local sqlite3 database to store information
SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db' SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db'
# Have the webserver deal with sending files rather than 0x0
USE_X_SENDFILE = True
FHOST_USE_X_ACCEL_REDIRECT = False
# Encrypted files really throw off mime guessers, which can cause some # Encrypted files really throw off mime guessers, which can cause some
# encrypted images to get rejected for having ELF headers (e.g. looking like # encrypted images to get rejected for having ELF headers (e.g. looking like
# executables). We don't want this, so we disable MIME filtering # executables). We don't want this, so we disable MIME filtering
@ -98,10 +96,10 @@ ln -fs /path/to/aviary/dist/www/index.html templates/404.html
gunicorn fhost:app gunicorn fhost:app
``` ```
You'll also need to serve the `index.js` file generated during the **building** You'll also need to serve the `aviary.min.js` file generated during the
step at `/index.js`. This can be done using an external webserver. A sample **building** step at `/aviary.min.js`. This can be done using an external
`Caddyfile` exists in `:dist/`. To use this, run the following command from webserver. A sample `Caddyfile` exists in `:dist/`. To use this, run the
the `dist/` directory. following command from the `dist/` directory.
```bash ```bash
caddy run caddy run

17
dist/Caddyfile vendored
View File

@ -1,5 +1,16 @@
http://localhost:6660 { http://localhost:6660 {
root www/ route {
file_server /index.js file_server /aviary.min.js {
reverse_proxy localhost:8000 pass_thru
root www/
}
reverse_proxy localhost:8000 {
@accel header X-Accel-Redirect *
handle_response @accel {
root * /path/to/0x0/
rewrite * {rp.header.X-Accel-Redirect}
file_server
}
}
}
} }

2
dist/www/index.html vendored
View File

@ -203,7 +203,7 @@ p {
border-radius: 50%; border-radius: 50%;
} }
</style> </style>
<script src="/index.js"></script> <script src="/aviary.min.js"></script>
<script src="https://unpkg.com/rescript-blurhash@0.4.0/dist/production.min.js"></script> <script src="https://unpkg.com/rescript-blurhash@0.4.0/dist/production.min.js"></script>
</head> </head>
<body> <body>

1
dist/www/index.js vendored
View File

@ -1 +0,0 @@
../index.js