1
1
mirror of https://github.com/primer/css.git synced 2024-12-02 07:53:06 +03:00
css/script/build

30 lines
711 B
Plaintext
Raw Normal View History

2019-01-29 01:52:45 +03:00
#!/bin/bash
set -e
outdir=build
rm -rf $outdir
2019-02-05 01:27:39 +03:00
mkdir -p src/$outdir
2019-01-29 01:52:45 +03:00
2019-02-05 01:27:39 +03:00
pushd src > /dev/null
indexes=$(find . -name index.scss | perl -pe 's#^\./##')
2019-01-29 01:52:45 +03:00
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 "[build] $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
2019-02-05 01:27:39 +03:00
popd > /dev/null
mv src/$outdir $outdir