Nuxt/packages/nitro/src/presets/cloudflare.ts

24 lines
868 B
TypeScript
Raw Normal View History

2020-11-20 00:16:31 +00:00
import { resolve } from 'upath'
import consola from 'consola'
import { extendPreset, writeFile, prettyPath } from '../utils'
2021-01-22 19:55:59 +00:00
import { NitroContext, NitroPreset } from '../context'
2020-11-20 00:16:31 +00:00
import { worker } from './worker'
2021-01-22 19:55:59 +00:00
export const cloudflare: NitroPreset = extendPreset(worker, {
2020-11-20 00:16:31 +00:00
entry: '{{ _internal.runtimeDir }}/entries/cloudflare',
ignore: [
'wrangler.toml'
],
hooks: {
2021-01-22 19:55:59 +00:00
async 'nitro:compiled' ({ output, _nuxt }: NitroContext) {
await writeFile(resolve(output.dir, 'package.json'), JSON.stringify({ private: true, main: './server/index.mjs' }, null, 2))
2020-11-20 00:16:31 +00:00
await writeFile(resolve(output.dir, 'package-lock.json'), JSON.stringify({ lockfileVersion: 1 }, null, 2))
2020-11-20 12:14:16 +00:00
let inDir = prettyPath(_nuxt.rootDir)
if (inDir) {
inDir = 'in ' + inDir
}
consola.success('Ready to run `wrangler publish`', inDir)
2020-11-20 00:16:31 +00:00
}
}
})