https://github.com/phptuts/sappertypescriptstart
To help people get started with sapper and typescript
https://github.com/phptuts/sappertypescriptstart
Last synced: about 1 year ago
JSON representation
To help people get started with sapper and typescript
- Host: GitHub
- URL: https://github.com/phptuts/sappertypescriptstart
- Owner: phptuts
- Created: 2020-02-06T18:53:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T06:37:45.000Z (over 3 years ago)
- Last Synced: 2025-02-10T15:14:19.995Z (over 1 year ago)
- Language: JavaScript
- Size: 596 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sappper Typescript Template
All the credit and hard work came from this repo:
https://github.com/pyoner/svelte-typescript
## Install
```
npm install -g degit
degit github:phptuts/sappertypescriptstart my-app
cd my-app
cp .env-template .env
npm install
npm run dev
```
Once it loads you should see this in the terminal console and browser console. This means the environment variables are loading.
```console
ENVIRONMENT VARIABLES WORKING
DOES NOT EXIST.
```
## Typescript on components
This is required for visual code.
```typescript
```
## Environment Variables
Set your environment variables in the .env file. To access them use env.ts function / service. There is an example in the index.svelte component.
```typescript
import { onMount } from "svelte";
import { getEnvParam } from "../services/env";
// Server Side
console.log(getEnvParam("TEST", "Environment variables not working."));
console.log(getEnvParam("BAD_ENV", "DOES NOT EXIST."));
onMount(() => {
// Client Side
console.log("App mounted");
console.log(getEnvParam("TEST", "Environment variables not working."));
console.log(getEnvParam("BAD_ENV", "DOES NOT EXIST."));
});
Sapper project template
Typescript Envs
```