aboutsummaryrefslogtreecommitdiff
path: root/svelte.config.js
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-02-22 22:03:39 +0000
committermat <github@matdoes.dev>2022-02-22 22:03:39 +0000
commit2a82b78f0a4a0aa23c16ac5debbb7ad026f606c0 (patch)
tree5ce676d238efbb1aa71d54731ffdc39eb5df61d7 /svelte.config.js
parentd4e7c7c72086d72b0e056ebecd99ecb071da0739 (diff)
downloadskyblock-stats-2a82b78f0a4a0aa23c16ac5debbb7ad026f606c0.tar.gz
skyblock-stats-2a82b78f0a4a0aa23c16ac5debbb7ad026f606c0.tar.bz2
skyblock-stats-2a82b78f0a4a0aa23c16ac5debbb7ad026f606c0.zip
create index page
Diffstat (limited to 'svelte.config.js')
-rw-r--r--svelte.config.js51
1 files changed, 46 insertions, 5 deletions
diff --git a/svelte.config.js b/svelte.config.js
index 1d64bf4..c6ab18b 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,7 +1,48 @@
// import adapter from '@sveltejs/adapter-cloudflare'
import adapter from '@sveltejs/adapter-auto'
import preprocess from 'svelte-preprocess'
-// import { createHtmlPlugin } from 'vite-plugin-html'
+import fs from 'fs'
+import https from 'https'
+
+function fetch(url) {
+ return new Promise((resolve, reject) => {
+ let data = ''
+
+ const req = https.request(new URL(url), res => {
+ res.on('data', d => {
+ data += d
+ })
+
+ res.on('end', () => {
+ resolve(data)
+ })
+ })
+
+ req.on('error', error => {
+ reject(error)
+ })
+
+ req.end()
+ })
+}
+
+(async () => {
+ const API_URL = 'https://skyblock-api.matdoes.dev/'
+
+ // create a donators.json from the donators.txt
+ const donatorUuidsText = await fs.promises.readFile('src/donators.txt', {
+ encoding: 'utf8'
+ })
+ const donatorUuids = donatorUuidsText.split('\n').map(u => u.split(' ')[0]).filter(u => u)
+ const donators = await Promise.all(
+ donatorUuids.map(u => fetch(`${API_URL}player/${u}`)
+ .then(r => JSON.parse(r).player)
+ )
+ )
+ await fs.promises.writeFile('src/_donators.json', JSON.stringify(donators), {
+ encoding: 'utf8'
+ })
+})()
/** @type {import('@sveltejs/kit').Config} */
const config = {
@@ -18,7 +59,7 @@ const config = {
// host: '127.0.0.1'
// }
// }),
-
+
// Override http methods in the Todo forms
methodOverride: {
@@ -27,9 +68,9 @@ const config = {
// https://vitejs.dev/config/
vite: {
- // plugins: [createHtmlPlugin({
- // minify: true
- // })],
+ // plugins: [createHtmlPlugin({
+ // minify: true
+ // })],
build: {
rollupOptions: {
// external: ['discord-api-types/payloads/v9', 'discord-api-types', 'discord-api-types/v9'],