1
1
mirror of https://github.com/primer/css.git synced 2024-11-30 01:04:04 +03:00
css/script/dist
2019-02-04 15:37:52 -08:00

30 lines
709 B
Bash
Executable File

#!/bin/bash
set -e
outdir=dist
rm -rf $outdir
mkdir -p src/$outdir
pushd src > /dev/null
indexes=$(find . -name index.scss | perl -pe 's#^\./##')
root=$(pwd)
for index in $indexes; do
if [[ $index = "index.scss" ]]; then
dir=.
name="primer"
else
dir=$(dirname $index)
name=${dir//\//-}
fi
file="$outdir/$name.css"
pushd $dir > /dev/null
echo "[dist] $index -> $file"
npx node-sass --include-path=$root index.scss > "$root/$file"
npx cssstats "$root/$file" > "$root/$outdir/$name.json"
echo "module.exports = {cssstats: require('./$name.json')}" > "$root/$outdir/$name.js"
popd > /dev/null
done
popd > /dev/null
mv src/$outdir $outdir