|
|
|
|
|
by BiteCode_dev
1649 days ago
|
|
Here is a task that groups all static files from a web project into a directory. It has to make sure a bunch of directories exist, run a node js command to build some files from the proper dir, then run a python command to regroup them + all static files from all django apps into one dir. Simple. But then I had a problem I had to hack around. This required me to change an entry to a generated TOML file on the fly at every build. doit just lets me add a 5 lines python function that does whatever I want, and insert it between my bash tasks, and I'm done. def task_bundle_static_files():
def update_manifest():
conf = Path("var/static/manifest.toml")
data = toml.loads(conf.read_text())
data["./src/main.js"] = data["index.html"]
conf.write_text(toml.dumps(data))
return {
"actions": [
"mkdir -p ./var/static/",
"rm -fr ./var/static/* ",
"cd frontend/; npm run build",
"python manage.py collectstatic --noinput",
update_manifest,
"cp -r ./var/static/* ",
]
}
|
|