https://dev.kronoz.win/r/marzneshin.git
| 1 |
a47eb4c |
Dawsh |
2y ago |
import os |
| 2 |
a47eb4c |
Dawsh |
2y ago |
import subprocess |
| 3 |
a47eb4c |
Dawsh |
2y ago |
from pathlib import Path |
| 4 |
a47eb4c |
Dawsh |
2y ago |
|
| 5 |
a47eb4c |
Dawsh |
2y ago |
from config import DEBUG, VITE_BASE_API |
| 6 |
a47eb4c |
Dawsh |
2y ago |
|
| 7 |
a47eb4c |
Dawsh |
2y ago |
path = '/dashboard/' |
| 8 |
a47eb4c |
Dawsh |
2y ago |
base_dir = Path(__file__).parent |
| 9 |
a47eb4c |
Dawsh |
2y ago |
build_dir = base_dir / 'build' |
| 10 |
a47eb4c |
Dawsh |
2y ago |
|
| 11 |
a47eb4c |
Dawsh |
2y ago |
|
| 12 |
a47eb4c |
Dawsh |
2y ago |
def build(): |
| 13 |
a47eb4c |
Dawsh |
2y ago |
proc = subprocess.Popen( |
| 14 |
a47eb4c |
Dawsh |
2y ago |
['npm', 'run', 'build', '--', '--base', path, '--outDir', build_dir], |
| 15 |
a47eb4c |
Dawsh |
2y ago |
env={**os.environ, 'VITE_BASE_API': VITE_BASE_API}, |
| 16 |
a47eb4c |
Dawsh |
2y ago |
cwd=base_dir |
| 17 |
a47eb4c |
Dawsh |
2y ago |
) |
| 18 |
a47eb4c |
Dawsh |
2y ago |
proc.wait() |
| 19 |
a47eb4c |
Dawsh |
2y ago |
with open(build_dir / 'index.html', 'r') as file: |
| 20 |
a47eb4c |
Dawsh |
2y ago |
html = file.read() |
| 21 |
a47eb4c |
Dawsh |
2y ago |
with open(build_dir / '404.html', 'w') as file: |
| 22 |
f7af2b3 |
Dawsh |
2y ago |
file.write(html) |