# Builds the frontend for production

cd "$(dirname "$0")/.."

cd homeassistant/components/frontend/www_static
rm -rf core.js* frontend.html* webcomponents-lite.min.js* panels
cd home-assistant-polymer
npm run clean
npm run frontend_prod

cp bower_components/webcomponentsjs/webcomponents-lite.min.js ..
cp -r build/* ..
BUILD_DEV=0 node script/gen-service-worker.js
cp build/service_worker.js ..

cd ..

gzip -f -k -9 *.html *.js ./panels/*.html

# Generate the MD5 hash of the new frontend
cd ../../../..
script/fingerprint_frontend.py