quicker-redirects
gtmnayan 1 year ago
parent 7a29487607
commit 97bae379ec

@ -1,4 +1,5 @@
import js from './redirect.js?raw'; // @ts-expect-error custom suffix doesn't have types
import js from './redirect.js?minified';
// prerenderer will choke otherwise // prerenderer will choke otherwise
export const prerender = false; export const prerender = false;

@ -2,8 +2,26 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { browserslistToTargets } from 'lightningcss'; import { browserslistToTargets } from 'lightningcss';
import { readFile } from 'node:fs/promises'; import { readFile } from 'node:fs/promises';
import browserslist from 'browserslist'; import browserslist from 'browserslist';
import { transformWithEsbuild } from 'vite';
const plugins = [raw(['.ttf']), sveltekit()]; /** @type {import('vite').Plugin[]} */
const plugins = [
raw(['.ttf']),
sveltekit(),
{
name: 'minified-raw-js',
async load(id) {
if (id.endsWith('.js?minified')) {
const file = id.replace('?minified', '');
let code = await readFile(file, 'utf-8');
return `export default ${JSON.stringify(
(await transformWithEsbuild(code, file, { minify: true, format: 'esm' })).code
)}`;
}
}
}
];
// Only enable sharp if we're not in a webcontainer env // Only enable sharp if we're not in a webcontainer env
if (!process.versions.webcontainer) { if (!process.versions.webcontainer) {

Loading…
Cancel
Save