Update Astro and adapters

This commit is contained in:
Nikita Karamov 2024-02-12 21:12:27 +01:00
parent b7001edc6e
commit 8f61bc80c1
3 changed files with 717 additions and 954 deletions

View file

@ -7,14 +7,16 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineConfig } from "astro/config";
import lightningcss from "vite-plugin-lightningcss";
import cloudflare from "@astrojs/cloudflare";
import deno from "@astrojs/deno";
import netlify from "@astrojs/netlify/functions";
import netlify from "@astrojs/netlify";
import node from "@astrojs/node";
import vercel from "@astrojs/vercel/serverless";
import browserslist from "browserslist";
import { browserslistToTargets, transform } from "lightningcss";
let adapterConfig = {};
if (process.env.VERCEL) {
console.info("Using Vercel (serverless) adapter...");
@ -24,7 +26,7 @@ if (process.env.VERCEL) {
}),
};
} else if (process.env.CF_PAGES) {
console.info("Using Cloudflare adapter...");
console.info("Using Cloudflare (Pages) adapter...");
adapterConfig = {
adapter: cloudflare(),
};
@ -48,6 +50,29 @@ if (process.env.VERCEL) {
};
}
const lightningCssPlugin = () => {
const targets = browserslistToTargets(browserslist());
return {
name: "vite-plugin-lightningcss",
transform(source, id) {
if (!id.endsWith(".css")) return;
const { code, map } = transform({
filename: id,
code: Buffer.from(source),
minify: true,
sourceMap: true,
targets,
});
return {
code: code.toString(),
// eslint-disable-next-line unicorn/no-null
map: map ? map.toString() : null,
};
},
};
};
export default defineConfig({
site: "https://s2f.kytta.dev",
@ -55,6 +80,6 @@ export default defineConfig({
...adapterConfig,
vite: {
plugins: [lightningcss()],
plugins: [lightningCssPlugin()],
},
});

View file

@ -32,25 +32,27 @@
},
"browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead",
"dependencies": {
"@astrojs/cloudflare": "^7.7.1",
"@astrojs/cloudflare": "^9.0.0",
"@astrojs/deno": "^5.0.1",
"@astrojs/netlify": "^3.1.1",
"@astrojs/node": "^6.1.0",
"@astrojs/vercel": "^5.2.0",
"@astrojs/netlify": "^5.1.1",
"@astrojs/node": "^8.2.0",
"@astrojs/vercel": "^7.3.0",
"@nanostores/persistent": "^0.9.1",
"astro": "^3.6.4",
"astro": "^4.3.6",
"nanostores": "^0.9.5"
},
"devDependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/check": "^0.5.3",
"@types/node": "^18.17.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"browserslist": "^4.22.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-unicorn": "^51.0.1",
"husky": "^9.0.10",
"lightningcss": "^1.23.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prettier-plugin-astro": "^0.13.0",
@ -59,8 +61,7 @@
"stylelint": "^16.2.1",
"stylelint-config-standard-scss": "^13.0.0",
"svgo": "^3.2.0",
"typescript": "^5.3.3",
"vite-plugin-lightningcss": "^0.0.5"
"typescript": "^5.3.3"
},
"lint-staged": {
"*": "pnpm run fix:prettier",

File diff suppressed because it is too large Load diff