Created
July 6, 2016 12:33
-
-
Save vitorbritto/4c5493b88d864cac006936b5ddc8c3d1 to your computer and use it in GitHub Desktop.
Prepare and compile files using Shell Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Programa: build.sh | |
# Autor: Vitor Britto | |
# | |
# Descrição: | |
# Este script será responsável pelo build do projeto, o qual | |
# fará o processo de minificação e concatenação dos arquivos | |
# e preparação dos arquivos a serem colocados em produção. | |
# | |
# Uso: chmod u+x build.sh && ./build.sh | |
# | |
# Declarando as variáveis | |
DIST=”_build” | |
IGNORE=( | |
“assets/styles/style.css” | |
“assets/scripts/main.js” | |
“.editorconfig” | |
) | |
STYLE=”assets/styles” | |
SCRIPT=”assets/scripts” | |
# Minificar JS | |
echo -e “→ Minificando JS” | |
curl -X POST -s — data-urlencode “input@${SCRIPT}/main.js” http://javascript-minifier.com/raw > ${SCRIPT}/main.min.js | |
# Minificar CSS | |
echo -e “→ Minificando CSS” | |
curl -X POST -s — data-urlencode “input@${STYLE}/style.css” http://cssminifier.com/raw > ${STYLE}/style.min.css | |
# Copiar arquivos para pasta de destino | |
echo -e “→ Colocando arquivos em produção” | |
if [[ ! -d ${DIST} ]]; then | |
mkdir ${DIST} | |
fi | |
cp ./* ${DIST} | |
rm -rf ${IGNORE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment