#!/bin/bash
set -eu

rm -rf build

mkdir build
mkdir build/normal
mkdir build/dashboard

time npx elm make src/Main.elm --optimize --output=build/normal/elm.js 
time npx terser build/normal/elm.js  --no-rename --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --mangle --output=build/normal/elm.js 

time npx elm make src/Dashboard.elm --debug --output=build/dashboard/dashboard.js
time npx terser build/dashboard/dashboard.js --no-rename --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --mangle --output=build/dashboard/dashboard.js

cp docs/index.html     build/normal/200.html
cp docs/dashboard.html build/dashboard/200.html

cp docs/products.json build/normal/
cp docs/products.json build/dashboard/

cp docs/favicon.ico build/normal/
cp docs/favicon.ico build/dashboard/

cp docs/robots.txt build/normal/
cp docs/robots.txt build/dashboard/

cp docs/elm-ecommerce-logo.png build/normal/
cp docs/elm-ecommerce-logo.png build/dashboard/

cp docs/_redirects build/normal/
cp docs/_redirects build/dashboard/
