ข้ามไปยังเนื้อหา

Tooling, Testing & Deployment

หากคุณเคย deploy แอปพลิเคชัน Next.js มาก่อน คุณมี mental model สำหรับโมดูลนี้อยู่แล้ว: CLI ที่ขับเคลื่อน dev/build/preview, การตรวจสอบ TypeScript, ไฟล์ configuration, ระบบนิเวศ integration และ deployment target Astro แมปแบบหนึ่งต่อหนึ่งกับทุกเครื่องมือเหล่านั้น — เพียงแต่คำสั่งและชื่อไฟล์เปลี่ยนไป

Next.js / Reactสิ่งเทียบเท่าใน Astro
next devastro dev
next buildastro build
next startastro preview
next lintastro check (ตรวจสอบ type ในไฟล์ .astro)
next.config.jsastro.config.mjs
Next.js plugins (webpack)Astro integrations (@astrojs/*)
npm install @next/bundle-analyzernpx astro add react / npx astro add tailwind
Vercel / Netlify สำหรับ Next.jsVercel / Netlify adapters สำหรับ Astro
tsc --noEmitastro check ครอบคลุม .astro + .ts
Jest / VitestVitest (config เหมือนกัน; Astro ไม่มี test runner ในตัว)
บทเรียนสิ่งที่คุณจะเรียนรู้
Astro CLIastro dev / build / preview / add / check; scripts ใน package.json
Integrationsnpx astro add, astro.config.mjs, ระบบนิเวศ integration
astro checkตรวจสอบ type ในไฟล์ .astro, editor tooling เทียบกับ tsc/ESLint
Static vs SSRoutput: 'static' เทียบกับ output: 'server', adapters, prerender
Deployastro build, static hosts, SSR adapters, GitHub Actions CI
Next.js config
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: { domains: ['cdn.example.com'] },
};
module.exports = nextConfig;
// package.json scripts (typical Next project)
// "dev": "next dev"
// "build": "next build"
// "start": "next start"
// "lint": "next lint"
// "type-check": "tsc --noEmit"
Astro config
// astro.config.mjs
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import tailwind from '@astrojs/tailwind';
export default defineConfig({
integrations: [react(), tailwind()],
});
// package.json scripts (typical Astro project)
// "dev": "astro dev"
// "build": "astro build"
// "preview": "astro preview"
// "check": "astro check"
คำสั่ง Astro CLI ใดที่ใกล้เคียงกับ `next build` มากที่สุด?
`astro check` ทำอะไรที่ Next.js ไม่มีคำสั่งเดียวครอบคลุม?
ใน Astro, build output อยู่ที่ไหนโดย default?