Merge branch 'ditorodev' of git.lumeweb.com:LumeWeb/web3browser.io into ditorodev

This commit is contained in:
Juan Di Toro 2023-11-02 19:34:41 +01:00
commit dd6869e6a5
2 changed files with 38 additions and 31 deletions

View File

@ -1,20 +1,21 @@
import { defineConfig } from "astro/config"; import { defineConfig } from 'astro/config'
import react from "@astrojs/react"; import react from '@astrojs/react'
import tailwind from "@astrojs/tailwind"; import tailwind from '@astrojs/tailwind'
import optimizer from "vite-plugin-optimizer"; import optimizer from 'vite-plugin-optimizer'
import * as fs from "node:fs"; import * as fs from 'node:fs'
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
output: 'static',
integrations: [react(), tailwind({ applyBaseStyles: false })], integrations: [react(), tailwind({ applyBaseStyles: false })],
vite: { vite: {
server: server:
process.env.MODE === "development" process.env.MODE === 'development'
? { ? {
https: { https: {
cert: fs.readFileSync("./.local-ssl/localhost.pem"), cert: fs.readFileSync('./.local-ssl/localhost.pem'),
key: fs.readFileSync("./.local-ssl/localhost-key.pem"), key: fs.readFileSync('./.local-ssl/localhost-key.pem'),
}, },
} }
: {}, : {},
@ -23,9 +24,9 @@ export default defineConfig({
}, },
plugins: [ plugins: [
optimizer({ optimizer({
"node-fetch": 'node-fetch':
"const e = undefined; export default e;export {e as Response, e as FormData, e as Blob};", 'const e = undefined; export default e;export {e as Response, e as FormData, e as Blob};',
}), }),
], ],
}, },
}); })

View File

@ -3,7 +3,13 @@ import * as fs from "node:fs";
import * as path from "node:path"; import * as path from "node:path";
export const GET: APIRoute = ({ params, request }) => { export const GET: APIRoute = ({ params, request }) => {
if (process.env.MODE !== "development") {
return new Response();
}
const filePath = path.resolve(process.cwd(), "dist/sw.js"); const filePath = path.resolve(process.cwd(), "dist/sw.js");
const fileContents = fs.readFileSync(filePath); const fileContents = fs.readFileSync(filePath);
return new Response(fileContents, { status: 200, headers: { 'Content-Type': 'application/javascript' } }); return new Response(fileContents, {
} status: 200,
headers: { "Content-Type": "application/javascript" },
});
};