diff --git a/atst/assets.py b/atst/assets.py new file mode 100644 index 00000000..7f723f75 --- /dev/null +++ b/atst/assets.py @@ -0,0 +1,16 @@ +from webassets import Environment, Bundle +from atst.home import home + +environment = Environment( + directory=home.child("scss"), + url="/static" +) + +css = Bundle( + "atat.scss", + filters="scss", + output="../static/assets/out.%(version)s.css", + depends=("**/*.scss"), +) + +environment.register("css", css) diff --git a/atst/handler.py b/atst/handler.py index 6272743c..99ffa0f2 100644 --- a/atst/handler.py +++ b/atst/handler.py @@ -1,18 +1,8 @@ -from webassets import Environment, Bundle import tornado.web -from atst.home import home +from atst.assets import environment from atst.sessions import SessionNotFoundError -assets = Environment(directory=home.child("scss"), url="/static") -css = Bundle( - "atat.scss", - filters="scss", - output="../static/assets/out.css", - depends=("**/*.scss"), -) - -assets.register("css", css) -helpers = {"assets": assets} +helpers = {"assets": environment} class BaseHandler(tornado.web.RequestHandler): diff --git a/script/bootstrap b/script/bootstrap index f39656f0..ad26fe47 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,5 +1,8 @@ #!/bin/bash +# script/bootstrap: Resolve all dependencies that the application requires to +# run. + # If a command fails, exit the script set -e @@ -13,3 +16,6 @@ pipenv install --dev # Install uswds node module and dependencies npm install + +# Precompile assets for deployment +pipenv run webassets -m atst.assets build diff --git a/script/setup b/script/setup index 0ea6be6d..76cd5301 100755 --- a/script/setup +++ b/script/setup @@ -1,5 +1,8 @@ #!/bin/bash +# script/setup: Set up application for the first time after cloning, or set it +# back to the initial first unused state. + # If a command fails, exit the script set -e