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