Last active
November 21, 2020 02:31
-
-
Save alexmacarthur/8449f7e979be81dc9aadc9445037cff4 to your computer and use it in GitHub Desktop.
A ZSH function for generating a super-basic HTML playground with a running development server and JS file.
This file contains 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
# Usage: | |
# `playground project-name` | |
# | |
# This command will create a directory containing an HTML file, a hooked-up JS file, and turn on a development server. | |
function playground { | |
mkdir $1 && cd $1 | |
npm init --yes | |
echo "<!DOCTYPE html> | |
<html> | |
<head> | |
<style></style> | |
</head> | |
<body> | |
<h1>Welcome to your playground.</h1> | |
<script src=\"./script.js\"></script> | |
</body> | |
</html> | |
" > ./index.html | |
echo "console.log('Hi!');" > ./script.js | |
echo "node_modules" > ./.gitignore | |
git init | |
git add . | |
git commit -m "Initial commit." | |
npx snowpack dev | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment