File tree 12 files changed +44
-11
lines changed
12 files changed +44
-11
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,8 @@ RUN sudo npx playwright install-deps &&\
6
6
7
7
# Install additional packages
8
8
RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \
9
- trash-cli
9
+ trash-cli
10
+
11
+ # Install global npm packages
12
+ RUN npm install --global \
13
+ local-cors-proxy
Original file line number Diff line number Diff line change @@ -10,6 +10,4 @@ services:
10
10
environment :
11
11
TZ : ${TZ} # Timezone
12
12
GITHUB_TOKEN : ${GITHUB_TOKEN} # GitHub CLI
13
- API_URL : ' https://dummyjson.com'
14
- GA_MEAUSREMENT_ID : ' G-XXXXXXXXXX'
15
- ADSENSE_CLIENT_ID : ' ca-pub-XXXXXXXXXX'
13
+ API_URL : ' http://localhost:3000/proxy'
Original file line number Diff line number Diff line change
1
+ VITE_API_URL = " ${ API_URL } "
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # Production environment variables. Do not put sensitive information here!
2
+ VITE_API_URL = " https://dummyjson.com"
3
+ VITE_GA_MEASUREMENT_ID = "" # G-XXXXXXXXXX
4
+ VITE_ADSENSE_CLIENT_ID = "" # ca-pub-XXXXXXXXXX
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ node_modules
12
12
Thumbs.db
13
13
14
14
# Env
15
- .env
16
- .env. *
15
+ # .env
16
+ # .env.*
17
17
! .env.example
18
18
! .env.test
19
19
Original file line number Diff line number Diff line change 17
17
"*.css" : " tailwindcss"
18
18
},
19
19
"restoreTerminals.terminals" : [
20
+ {
21
+ "splitTerminals" : [
22
+ {
23
+ "name" : " mock api" ,
24
+ "commands" : [
25
+ " echo 'Pretending you have a local server running...'" ,
26
+ " echo 'You can delete this in your .vscode/settings.json.'" ,
27
+ " npx local-cors-proxy --proxyUrl https://dummyjson.com --port 3000"
28
+ ]
29
+ },
30
+ ]
31
+ },
20
32
{
21
33
"splitTerminals" : [
22
34
{
Original file line number Diff line number Diff line change 3
3
@import 'tailwindcss/utilities' ;
4
4
5
5
@layer base {
6
+ /* Toogle light/dark mode on your OS to see changes. */
6
7
body {
7
8
@apply font-sans antialiased;
8
9
@apply bg-white text-neutral-900;
Original file line number Diff line number Diff line change 1
1
/** See https://vite.dev/guide/env-and-mode#modes */
2
- export const IS_PRODUCTION_BUILD = import . meta. env . MODE === 'production' ;
2
+ export const BUILD_MODE = import . meta. env . MODE ;
3
+ export const IS_PRODUCTION_BUILD = BUILD_MODE === 'production' ;
3
4
4
5
/** Check if running on localhost or a local network. */
5
6
export const IS_LOCAL_ENVIRONMENT =
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { App } from './app';
6
6
import {
7
7
ADSENSE_CLIENT_ID ,
8
8
API_URL ,
9
+ BUILD_MODE ,
9
10
GA_MEASUREMENT_ID ,
10
11
IS_LOCAL_ENVIRONMENT ,
11
12
IS_PRODUCTION_BUILD
@@ -20,6 +21,7 @@ export const log = new Log(IS_PRODUCTION_BUILD ? Log.INFO : Log.TRACE);
20
21
21
22
log . debug ( init_start , 'Initializing...' ) ;
22
23
log . debug ( 'Config:' , {
24
+ BUILD_MODE ,
23
25
API_URL ,
24
26
IS_PRODUCTION_BUILD ,
25
27
IS_LOCAL_ENVIRONMENT ,
Original file line number Diff line number Diff line change 8
8
});
9
9
</script >
10
10
11
- <slot />
11
+ <main >
12
+ <slot />
13
+ </main >
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { app } from ' $lib' ;
3
+ import { API_URL } from ' $lib/config' ;
3
4
import { onMount } from ' svelte' ;
4
5
import SvelteLogo from ' virtual:icons/logos/svelte-icon' ;
6
+
5
7
let ad: HTMLElement ;
8
+ let testResult = $state (' ' );
9
+
6
10
onMount (() => {
7
11
app .advertising .loadAd (ad , ' adunit' , ' auto' );
12
+ testApi ();
8
13
});
14
+
15
+ async function testApi() {
16
+ const res = await fetch (` ${API_URL }/test ` );
17
+ testResult = JSON .stringify (await res .json ());
18
+ }
9
19
</script >
10
20
11
21
<article class =" p-2" >
12
22
<h1 >Welcome to SvelteKit <SvelteLogo class =" m-2 inline w-8" /></h1 >
13
23
<p >
14
24
Visit <a href =" https://svelte.dev/docs/kit" >svelte.dev/docs/kit</a > to read the documentation.
15
25
</p >
26
+ <p >API test: {testResult }</p >
16
27
<footer >
17
28
<ins bind:this ={ad } class =" block h-16 w-64" ></ins >
18
29
</footer >
You can’t perform that action at this time.
0 commit comments