😇
Nuxtで色々デプロイ
とりあえず登壇するので先に下書きであげておく(あとで修正する)
Nuxt install
$ docker run --rm -v $(pwd):/app -w /app -p 85:80 -it node:lts-slim /bin/bash
$ npx nuxi@latest init .
AWS Amplify
手順に従ってデプロイ
Cloudflare Pages
$ npm install -g wrangler
$ npx nuxi build --preset=cloudflare_pages
$ export CLOUDFLARE_ACCOUNT_ID=yyy
$ export CLOUDFLARE_API_TOKEN=xxx
$ npx wrangler pages deploy dist/
環境変数設定しないとエラーがでます。
$ npx wrangler pages deploy dist/
✘ [ERROR] A request to the Cloudflare API (/memberships) failed.
Authentication error [code: 10000]
📎 It looks like you are authenticating Wrangler via a custom API token set in an environment variable.
Please ensure it has the correct permissions for this operation.
Getting User settings...
👋 You are logged in with an API Token. Unable to retrieve email for this user. Are you missing the `User->User Details->Read` permission?
Vercel
このドキュメントになぞってデプロイするだけ(簡単!)
Firebase
nitroのドキュメントを参照した上で下記進めてもらえると
Firebase console上でのプロジェクト作成はskip
$ npm install -g firebase-tools@latest
$ firebase login --no-localhost
$ firebase init hosting
$ apt update -y && apt install python3 make gcc g++ -y
$ npm i firebase-admin firebase-functions firebase-functions-test
nuxt.config.ts
とfirebase.json
を修正する。
nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
nitro: {
preset: 'firebase',
firebase: {
nodeVersion: '18',
gen: 1,
region: 'us-central1'
}
}
})
firebase.json
{
"functions": { "source": ".output/server" },
"hosting": {
"public": ".output/public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"cleanUrls": true,
"rewrites": [{ "source": "**", "function": "server" }]
}
}
$ NITRO_PRESET=firebase npm run build
$ firebase deploy --only functions:server,hosting
Discussion