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

24 lines
867 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'
import { SigmaContext, SigmaPreset } from '../context'
import { worker } from './worker'
export const cloudflare: SigmaPreset = extendPreset(worker, {
entry: '{{ _internal.runtimeDir }}/entries/cloudflare',
ignore: [
'wrangler.toml'
],
hooks: {
async 'sigma:compiled' ({ output, _nuxt }: SigmaContext) {
await writeFile(resolve(output.dir, 'package.json'), JSON.stringify({ private: true, main: './server/index.js' }, null, 2))
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
}
}
})