Install Astro instead of Vite

This commit is contained in:
Nikita Karamov 2023-03-17 21:08:08 +01:00
parent 48e6fc3fc7
commit 1ba204644b
No known key found for this signature in database
GPG Key ID: 41D6F71EE78E77CD
7 changed files with 2786 additions and 1573 deletions

View File

@ -1,15 +1,28 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:unicorn/recommended",
"plugin:astro/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": {
"browser": true
},
"extends": ["eslint:recommended", "plugin:unicorn/recommended", "prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"overrides": [
{
"files": ["api/*.js"],
"files": ["*.astro"],
"parser": "astro-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"extraFileExtensions": [".astro"]
}
},
{
"files": ["api/*.js", "astro.config.ts"],
"env": {
"node": true,
"browser": false
@ -17,6 +30,12 @@
"rules": {
"unicorn/prefer-node-protocol": 0
}
},
{
"files": ["src/env.d.ts"],
"rules": {
"unicorn/prevent-abbreviations": 0
}
}
]
}

25
astro.config.ts Normal file
View File

@ -0,0 +1,25 @@
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
import node from "@astrojs/node";
import vercel from "@astrojs/vercel/serverless";
let astroAdapter;
if (process.env.VERCEL) {
console.debug("Using Vercel adapter");
astroAdapter = vercel();
} else if (process.env.NETLIFY) {
console.debug("Using Netlify adapter");
astroAdapter = netlify();
} else {
console.debug("Using Node.js adapter");
astroAdapter = node({
mode: "standalone",
});
}
export default defineConfig({
site: "https://s2f.kytta.dev",
adapter: astroAdapter,
output: "server",
});

View File

@ -12,33 +12,38 @@
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite",
"fmt": "prettier --write .",
"build": "astro build",
"dev": "astro dev",
"fmt": "prettier --write --plugin-search-dir=. .",
"lint": "prettier --check . && eslint . && stylelint '**/*.scss'",
"preview": "vite preview",
"preview": "astro preview",
"start": "astro dev",
"test": "pnpm run lint"
},
"browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead",
"dependencies": {
"@astrojs/netlify": "^2.2.0",
"@astrojs/node": "^5.1.0",
"@astrojs/vercel": "^3.2.1",
"astro": "^2.1.3"
},
"devDependencies": {
"@vitejs/plugin-legacy": "^4.0.2",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"autoprefixer": "^10.4.14",
"browserslist": "^4.21.5",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-astro": "^0.25.0",
"eslint-plugin-unicorn": "^46.0.0",
"postcss": "^8.4.21",
"postcss-csso": "^6.0.1",
"prettier": "^2.8.4",
"prettier-plugin-astro": "^0.8.0",
"sass": "^1.59.3",
"sharp": "^0.31.3",
"stylelint": "^15.2.0",
"stylelint-config-standard-scss": "^7.0.1",
"svgo": "^3.0.2",
"terser": "^5.16.6",
"vite": "^4.2.0",
"vite-plugin-image-optimizer": "^1.1.2",
"vite-plugin-node": "^3.0.2"
"typescript": "^5.0.2"
},
"postcss": {
"map": true,

File diff suppressed because it is too large Load Diff

1
src/env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="astro/client" />

3
tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}

View File

@ -1,25 +0,0 @@
import legacy from "@vitejs/plugin-legacy";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import { VitePluginNode } from "vite-plugin-node";
const vitePluginNode = VitePluginNode({
// Workaround from: https://github.com/axe-me/vite-plugin-node/issues/47
adapter({ app, req, res, next }) {
if (req.url.startsWith("/api/")) {
app(req, res);
} else {
next();
}
},
appPath: "./api/share.js",
});
vitePluginNode[0].apply = "serve";
export default {
build: {
minify: "terser",
terserOptions: { ecma: 5 },
sourcemap: "true",
},
plugins: [legacy(), ...vitePluginNode, ViteImageOptimizer({})],
};