mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 02:44:51 +00:00
24 lines
1017 B
TypeScript
24 lines
1017 B
TypeScript
import { resolve } from 'pathe'
|
|
import consola from 'consola'
|
|
import { extendPreset, writeFile, prettyPath, hl } from '../utils'
|
|
import { NitroContext, NitroPreset } from '../context'
|
|
import { worker } from './worker'
|
|
|
|
export const cloudflare: NitroPreset = extendPreset(worker, {
|
|
entry: '{{ _internal.runtimeDir }}/entries/cloudflare',
|
|
ignore: [
|
|
'wrangler.toml'
|
|
],
|
|
hooks: {
|
|
async 'nitro:compiled' ({ output, _nuxt }: NitroContext) {
|
|
await writeFile(resolve(output.dir, 'package.json'), JSON.stringify({ private: true, main: './server/index.mjs' }, null, 2))
|
|
await writeFile(resolve(output.dir, 'package-lock.json'), JSON.stringify({ lockfileVersion: 1 }, null, 2))
|
|
let inDir = prettyPath(_nuxt.rootDir)
|
|
if (inDir) {
|
|
inDir = 'in ' + inDir
|
|
}
|
|
consola.success('Ready to run', hl('npx wrangler publish ' + inDir), 'or', hl('npx miniflare ' + prettyPath(output.serverDir) + '/index.mjs --site ' + prettyPath(output.publicDir)), 'for local testing')
|
|
}
|
|
}
|
|
})
|