Skip to content

Commit

Permalink
Revert "Vercel migration (#57)" (#58)
Browse files Browse the repository at this point in the history
This reverts commit 554cfdc.
  • Loading branch information
tony-sull authored Sep 26, 2023
1 parent 554cfdc commit 938b7c2
Show file tree
Hide file tree
Showing 17 changed files with 3,708 additions and 3,281 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# build output
dist
.vercel
.netlify

# dependencies
node_modules/
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pnpm-lock.yaml
.vercel
20 changes: 10 additions & 10 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// @ts-expect-error: module types don't work in this version
import netlify from '@astrojs/netlify/functions';
import tailwind from '@astrojs/tailwind';
import vercel from '@astrojs/vercel/serverless';
import { defineConfig } from 'astro/config';

/* https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables */
const VERCEL_PREVIEW_SITE =
process.env.VERCEL_ENV !== 'production' &&
process.env.VERCEL_URL &&
`https://${process.env.VERCEL_URL}`;
/* https://docs.netlify.com/configure-builds/environment-variables/#read-only-variables */
const NETLIFY_PREVIEW_SITE = process.env.CONTEXT !== 'production' && process.env.DEPLOY_PRIME_URL;

// https://astro.build/config
export default defineConfig({
site: VERCEL_PREVIEW_SITE || 'https://astro.new',
site: NETLIFY_PREVIEW_SITE || 'https://astro.new',
integrations: [
tailwind({
configFile: './tailwind.config.mjs',
applyBaseStyles: false,
config: {
path: './tailwind.config.mjs',
applyBaseStyles: false,
},
}),
],
output: 'server',
adapter: vercel(),
adapter: netlify(),
vite: {
ssr: {
noExternal: ['smartypants'],
Expand Down
4 changes: 4 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[dev]
command = "astro dev"
targetPort = 3000
publish = "public"
27 changes: 27 additions & 0 deletions netlify/functions/nightly-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { schedule } from '@netlify/functions';

const nightlyBuildHook = process.env.NIGHTLY_BUILD_HOOK;
if (!nightlyBuildHook) {
throw new Error('NIGHTLY_BUILD_HOOK environment variable is undefined');
}

export const handler = schedule('0 8 * * *', async function handler() {
try {
const response = await fetch(nightlyBuildHook, {
method: 'POST',
body: JSON.stringify({}),
headers: { 'Content-Type': 'application/json' },
});

if (!response.ok) {
// NOT res.status >= 200 && res.status < 300
return { statusCode: response.status, body: response.statusText };
}

return { statusCode: 200 };
} catch (error) {
// output to netlify function log
console.error(error);
return { statusCode: 500, body: 'An internal error occurred' };
}
});
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"node": "18"
},
"scripts": {
"dev": "astro dev",
"dev": "netlify dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
Expand All @@ -25,26 +25,24 @@
},
"prettier": "@astrojs/site-kit/prettier",
"dependencies": {
"@astrojs/check": "^0.2.0",
"@astrojs/vercel": "^5.0.1",
"@fontsource-variable/inter": "^5.0.8",
"@astrojs/netlify": "^2.2.2",
"@fontsource/inter": "^4.5.15",
"title": "^3.5.3"
},
"devDependencies": {
"@astrojs/site-kit": "github:withastro/site-kit",
"@astrojs/tailwind": "^5.0.0",
"@astrojs/tailwind": "^3.1.1",
"@netlify/functions": "^1.4.0",
"@tailwindcss/container-queries": "^0.1.1",
"@types/node": "^20.6.5",
"@types/node": "^18.15.11",
"@types/title": "^3.4.1",
"astro": "^3.1.3",
"astro-icon": "^0.8.1",
"eslint": "^8.50.0",
"astro": "^2.2.3",
"astro-icon": "^0.8.0",
"eslint": "^8.49.0",
"install": "^0.13.0",
"netlify-cli": "^16.4.2",
"netlify-cli": "^13.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.0",
"prettier-plugin-tailwindcss": "^0.5.4",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
},
Expand Down
Loading

0 comments on commit 938b7c2

Please sign in to comment.