DEST=priv/static NODE_ENV=production JS_TARGETS=\ app.js EDBUILD_FLAGS=--bundle --target=es2016 --minify ESBUILD_WATCH_FLAGS=--bundle --target=es2016 --sourcemap=inline CSS_TARGETS=\ app.css TAILWINDCSS_FLAGS=--postcss --minify TAILWINDCSS_WATCH_FLAGS=--postcss DIR_TARGETS=\ assets/images:images STATIC_TARGETS=\ assets/node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm:graphvizlib.wasm\ assets/node_modules/@hpcc-js/wasm/dist/index.min.js:hpcc.wasm.min.js\ assets/images/favicon.ico:favicon.ico .export NODE_ENV TARGETS= COMPRESS= PHONIES= .for _t in ${JS_TARGETS} #.info "[JS] ${_t:S/^/assets\//} --> ${_t:S/^/${DEST}\//}" ${_t:S/^/${DEST}\//}: ${_t:S/^/assets\//} assets/lib @mkdir -p ${_t:S/^/${DEST}\//:H} cd assets; npx esbuild ${_t} ${ESBUILD_FLAGS} --outfile=../${_t:S/^/${DEST}\//} COMPRESS+=${_t:S/^/${DEST}\//} ${_t:S/^/watch@/}: @mkdir -p ${_t:S/^/${DEST}\//:H} cd assets; npx esbuild ${_t:S/assets\//} --watch ${ESBUILD_WATCH_FLAGS} --outfile=../${_t:S/^/${DEST}\//} PHONIES+=${_t:S/^/watch@/} .endfor .for _t in ${CSS_TARGETS} #.info "[CSS] ${_t:S/^/assets\//} --> ${_t:S/^/${DEST}\//}" ${_t:S/^/${DEST}\//}: ${_t:S/^/assets\//} assets/css @mkdir -p ${_t:S/^/${DEST}\//:H} cd assets; npx tailwindcss ${TAILWINDCSS_FLAGS} -i ${_t} -o ${_t:S/^/${DEST}\//} COMPRESS+=${_t:S/^/${DEST}\//} ${_t:S/^/watch@/}: ${_t:S/^/assets\//} @mkdir -p ${_t:S/^/${DEST}\//:H} cd assets; npx tailwindcss --watch ${TAILWINDCSS_WATCH_FLAGS} -i ${_t} -o ${_t:S/^/${DEST}\//} PHONIES+=${_t:S/^/watch@/} .endfor .for _t in ${DIR_TARGETS} #.info "[DIR] ${_t:C/\:.*$/\//} --> ${_t:C/^.*\:/${DEST}\//:S/$/\//}" ${_t:C/^.*\://:S/\//_/:S/^/_build\/.make-assets-dir_/}: ${_t:C/\:.*$/\//} @mkdir -p ${_t:C/^.*\:/${DEST}\//:S/$/\//:H} rsync --archive --delete ${_t:C/\:.*$/\//} ${_t:C/^.*\:/${DEST}\//:S/$/\//} @touch ${_t:C/^.*\://:S/\//_/:S/^/_build\/.make-assets-dir_/} TARGETS+=${_t:C/^.*\://:S/\//_/:S/^/_build\/.make-assets-dir_/} .endfor .for _t in ${STATIC_TARGETS} #.info "[STATIC] ${_t:C/\:.*$//} -> ${_t:C/^.*\:/${DEST}\//}" ${_t:C/^.*\:/${DEST}\//}: ${_t:C/\:.*$//} @mkdir -p ${_t:C/^.*\:/${DEST}\//:H} cp ${_t:C/\:.*$//} ${_t:C/^.*\:/${DEST}\//} TARGETS+=${_t:C/^.*\:/${DEST}\//} .endfor .for _c in ${COMPRESS} #.info "[COMPRESS] ${_c}" ${_c:S/$/.gz/}: ${_c} gzip --force --keep ${.ALLSRC} TARGETS+=${_c:S/$/.gz/} ${_c:S/$/.br/}: ${_c} brotli --force --keep ${.ALLSRC} TARGETS+=${_c:S/$/.br/} .endfor #.info "Compressable: ${COMPRESS}" #.info "Targets: ${TARGETS}" all: ${TARGETS} clean: rm -r ${DEST} .MAIN: all .PHONY: all clean ${PHONIES}