diff options
author | syn <isaqtm@gmail.com> | 2021-03-08 21:23:24 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2021-03-08 21:23:24 +0300 |
commit | 2f38658f5d86a199a1066341883aa69bd6e49828 (patch) | |
tree | 6493c73076c2fdef371d40d285197499505db604 | |
parent | 82b3f4c5e419bd6fdaa0dae14c92586b51aee8d7 (diff) | |
download | upnet-2f38658f5d86a199a1066341883aa69bd6e49828.tar.gz |
Improve build process
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | back/app.py | 15 | ||||
-rw-r--r-- | back/config.py | 2 | ||||
-rw-r--r-- | front/index.html | 6 | ||||
-rw-r--r-- | front/package.json | 2 | ||||
-rw-r--r-- | front/style.css | 8 |
6 files changed, 18 insertions, 17 deletions
@@ -2,4 +2,4 @@ front/node_modules/ backenv/ back/__pycache__/ - +front/dist/ diff --git a/back/app.py b/back/app.py index 7d082d4..0d7bbee 100644 --- a/back/app.py +++ b/back/app.py @@ -1,7 +1,7 @@ from __future__ import annotations from sanic import Sanic from sanic.response import json as response_json, file -from config import APP_DIR +from config import APP_DIR, debug as is_debug from aioredis import create_redis_pool from dataclasses import dataclass, fields, asdict import json @@ -10,12 +10,11 @@ from math import floor app = Sanic(__name__) -app.static("/", APP_DIR + "/../front/index.html") -app.static("/js/out.js", APP_DIR + "/../front/out.js") -app.static("/css/style.css", APP_DIR + "/../front/style.css") -app.static("/css/twemoji-awesome.css", APP_DIR + "/../front/twemoji-awesome.css") -app.static("/AnkaCoder/", APP_DIR + "/../front/AnkaCoder") -app.static("/AnkaCoderCondensed/", APP_DIR + "/../front/AnkaCoderCondensed") +if is_debug: + # in release environment, these will be served by nginx + # but in debug, we serve this shit directly. + # app.static("/", APP_DIR + "/../front/index.html") + app.static("/", APP_DIR + "/../front/dist/") def now_ms() -> int: @@ -103,4 +102,4 @@ async def get_todos(req): return response_json({ "todos": todos }) if __name__ == "__main__": - app.go_fast(host="0.0.0.0", port=8000, debug=True) + app.go_fast(host="0.0.0.0", port=8000, debug=is_debug) diff --git a/back/config.py b/back/config.py index a3185ee..9c5b6fd 100644 --- a/back/config.py +++ b/back/config.py @@ -10,3 +10,5 @@ if modpath.endswith('.pyc') and os.path.exists(modpath[:-1]): # Sort out symlinks APP_DIR = os.path.realpath(os.path.dirname(modpath)) REDIS_HOST = 'localhost' + +debug = True diff --git a/front/index.html b/front/index.html index 52f1d2e..46c4627 100644 --- a/front/index.html +++ b/front/index.html @@ -5,12 +5,12 @@ <title> пиздец </title> <meta name="theme-color" content="#141D20"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="stylesheet" href="/css/style.css"> - <link rel="stylesheet" href="/css/twemoji-awesome.css"> + <link rel="stylesheet" href="/style.css"> + <link rel="stylesheet" href="/twemoji-awesome.css"> </head> <body> <div id="root"> </div> - <script defer src="/js/out.js"></script> + <script defer src="/index.js"></script> </body> </html>
\ No newline at end of file diff --git a/front/package.json b/front/package.json index 941b9c4..0a96871 100644 --- a/front/package.json +++ b/front/package.json @@ -14,7 +14,7 @@ "scripts": { "test": "echo \"Error: testing is disallowed\" && exit 1", "build": "esbuild index.jsx --sourcemap=inline --bundle --outdir=dist", - "release": "esbuild index.jsx --bundle --minify --outdir=dist", + "release": "esbuild index.jsx style.css twemoji-awesome.css --loader:.ttf=file --bundle --minify --outdir=dist && cp index.html dist/", "watch": "esbuild index.jsx --sourcemap=inline --bundle --outdir=dist --watch" }, "author": "syn", diff --git a/front/style.css b/front/style.css index 3ef2ea1..c944736 100644 --- a/front/style.css +++ b/front/style.css @@ -1,20 +1,20 @@ @font-face { font-family: 'Anka/Coder'; - src: url("/AnkaCoderCondensed/AnkaCoder-C87-r.ttf") format('truetype'); + src: url("./AnkaCoderCondensed/AnkaCoder-C87-r.ttf") format('truetype'); } @font-face { font-family: 'Anka/Coder'; - src: url("/AnkaCoderCondensed/AnkaCoder-C87-i.ttf") format('truetype'); + src: url("./AnkaCoderCondensed/AnkaCoder-C87-i.ttf") format('truetype'); font-style: italic; } @font-face { font-family: 'Anka/Coder'; - src: url("/AnkaCoderCondensed/AnkaCoder-C87-b.ttf") format('truetype'); + src: url("./AnkaCoderCondensed/AnkaCoder-C87-b.ttf") format('truetype'); font-weight: bold; } @font-face { font-family: 'Anka/Coder'; - src: url("/AnkaCoderCondensed/AnkaCoder-C87-b.ttf") format('truetype'); + src: url("./AnkaCoderCondensed/AnkaCoder-C87-b.ttf") format('truetype'); font-style: italic; font-weight: bold; } |