Created
April 16, 2020 14:37
-
-
Save henryjameslau/cbe1ffe5f7587f495f7ce5446858adaf to your computer and use it in GitHub Desktop.
Launch live-server with middleware with gzip content encoding
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 | |
# bash script to set up a gzip js as middleware for live-server | |
if test -f gzip.js; then | |
echo "gzip.js exists, launching live-server" | |
live-server --middleware="${PWD}/gzip.js" | |
else | |
echo "module.exports = function(req, res, next) { | |
if (req.url.endsWith('.pbf')) { | |
next(); | |
res.setHeader('Content-Encoding', 'gzip'); | |
} else { | |
next(); | |
} | |
}" > "gzip.js" | |
live-server --middleware="${PWD}/gzip.js" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment