mirror of
https://github.com/revanced/revanced-website.git
synced 2025-05-20 15:17:07 +02:00
parent
8f031178b3
commit
8d73663ae3
3
netlify.toml
Normal file
3
netlify.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[build]
|
||||||
|
publish = "public/"
|
||||||
|
command = "npm run build"
|
@ -1,82 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
// This code was stolen from https://github.com/sveltejs/kit/blob/master/packages/adapter-static/platforms.js
|
|
||||||
|
|
||||||
// sveltekit does things like this instead of actually just using ts for some reason.
|
|
||||||
/** @param {import('@sveltejs/kit').Builder} builder */
|
|
||||||
function vercel_routes(builder) {
|
|
||||||
/** @type {any[]} */
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
src: `/${builder.config.kit.appDir}/immutable/.+`,
|
|
||||||
headers: {
|
|
||||||
'cache-control': 'public, immutable, max-age=31536000'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// explicit redirects
|
|
||||||
for (const [src, redirect] of builder.prerendered.redirects) {
|
|
||||||
routes.push({
|
|
||||||
src,
|
|
||||||
headers: {
|
|
||||||
Location: redirect.location
|
|
||||||
},
|
|
||||||
status: redirect.status
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// prerendered pages
|
|
||||||
for (const [src, page] of builder.prerendered.pages) {
|
|
||||||
routes.push({
|
|
||||||
src,
|
|
||||||
dest: `__revanced/prerendered/${page.file}`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// implicit redirects (trailing slashes)
|
|
||||||
for (const [src] of builder.prerendered.pages) {
|
|
||||||
if (src !== '/') {
|
|
||||||
routes.push({
|
|
||||||
src: src.endsWith('/') ? src.slice(0, -1) : src + '/',
|
|
||||||
headers: {
|
|
||||||
location: src
|
|
||||||
},
|
|
||||||
status: 308
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
routes.push({
|
|
||||||
handle: 'filesystem'
|
|
||||||
});
|
|
||||||
|
|
||||||
return routes;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function wrap(adapter, opts) {
|
|
||||||
if (!process.env.VERCEL) {
|
|
||||||
// we don't have to bother :)
|
|
||||||
return adapter(opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
opts.pages = `.vercel/output/static/__revanced/prerendered`
|
|
||||||
opts.assets = '.vercel/output/static';
|
|
||||||
|
|
||||||
adapter = adapter(opts);
|
|
||||||
|
|
||||||
const adapt_fn = adapter.adapt;
|
|
||||||
adapter.adapt = async (builder) => {
|
|
||||||
const result = await adapt_fn(builder);
|
|
||||||
fs.writeFileSync(
|
|
||||||
'.vercel/output/config.json',
|
|
||||||
JSON.stringify({
|
|
||||||
version: 3,
|
|
||||||
routes: vercel_routes(builder)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter;
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
import adapter from '@sveltejs/adapter-static';
|
import adapter from '@sveltejs/adapter-static';
|
||||||
import preprocess from 'svelte-preprocess';
|
import preprocess from 'svelte-preprocess';
|
||||||
|
|
||||||
import { wrap } from './src/_vercel-moment.js';
|
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||||
@ -12,7 +10,7 @@ const config = {
|
|||||||
kit: {
|
kit: {
|
||||||
// adapter-static has vercel detection, but that does not let you set a custom 404 page easily.
|
// adapter-static has vercel detection, but that does not let you set a custom 404 page easily.
|
||||||
// Instead, we have to use a wrapper that generates a vercel config if on vercel...
|
// Instead, we have to use a wrapper that generates a vercel config if on vercel...
|
||||||
adapter: wrap(adapter, {
|
adapter: adapter({
|
||||||
pages: "public",
|
pages: "public",
|
||||||
fallback: "404.html"
|
fallback: "404.html"
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user