Skip to content

Instantly share code, notes, and snippets.

@frankievalentine
Created October 21, 2020 04:52
Show Gist options
  • Save frankievalentine/a33d0646a8a951082d9bc68945bb422f to your computer and use it in GitHub Desktop.
Save frankievalentine/a33d0646a8a951082d9bc68945bb422f to your computer and use it in GitHub Desktop.
snowpack-svelte

Directory Setup

├── public
│   ├── favicon.ico
│   ├── global.css
│   ├── index.html
│   ├── robots.txt
├── src
│   ├── App.svelte
│   ├── index.js
├── .gitignore
├── snowpack.config.js
└── package.json
<script>
export let name;
</script>
<style>
h1 {
text-align: center;
}
</style>
<h1>Hello {name}!</h1>
import App from "./App.svelte";
const app = new App({
target: document.body,
props: {
name: "Svelte",
},
});
export default app;
// Hot Module Replacement (HMR) - Remove this snippet to remove HMR.
// Learn more: https://www.snowpack.dev/#hot-module-replacement
if (import.meta.hot) {
import.meta.hot.accept();
import.meta.hot.dispose(() => {
app.$destroy();
});
}
{
"scripts": {
"start": "snowpack dev",
"build": "snowpack build",
}
{
"plugins": ["@snowpack/plugin-svelte"]
}
mkdir [dirname]
cd [dirname]
yarn init -y
git init
touch .gitignore && echo -e "node_modules\nyarn.lock\nyarn-error.log\ndist\n.cache\n.env" >> .gitignore
yarn add --dev snowpack svelte-check @snowpack/plugin-svelte @snowpack/plugin-run-script @snowpack/app-scripts-svelte
yarn add svelte
mkdir public && mkdir src && cd public && touch favicon.ico global.css index.html robots.txt
cd .. && cd src
touch App.svelte index.js && cd ..
touch snowpack.config.js
hub create
code .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment