feat: make cloudflare working

This commit is contained in:
Pooya Parsa 2020-11-06 17:40:00 +01:00
parent 25290b7aa0
commit 5b8314245c
2 changed files with 23 additions and 4 deletions

View File

@ -36,7 +36,8 @@ export const getRollupConfig = (config: SLSOptions) => {
const providedDeps = [ const providedDeps = [
'@nuxt/devalue', '@nuxt/devalue',
'vue-bundle-renderer' 'vue-bundle-renderer',
'@cloudflare/kv-asset-handler'
] ]
const extensions = ['.ts', '.mjs', '.js', '.json', '.node'] const extensions = ['.ts', '.mjs', '.js', '.json', '.node']

View File

@ -1,7 +1,25 @@
import { extendTarget } from '../utils' import { resolve } from 'path'
import { SLSTarget } from '../config' import { writeFile } from 'fs-extra'
import consola from 'consola'
import { extendTarget, prettyPath } from '../utils'
import { SLSOptions, SLSTarget } from '../config'
import { worker } from './worker' import { worker } from './worker'
export const cloudflare: SLSTarget = extendTarget(worker, { export const cloudflare: SLSTarget = extendTarget(worker, {
entry: '{{ runtimeDir }}/cloudflare',
generateIgnore: [
'wrangler.toml'
],
hooks: {
async done ({ targetDir }: SLSOptions) {
const pkgPath = resolve(targetDir, 'package.json')
const pkg = {
private: true,
main: './_nuxt.js'
}
await writeFile(pkgPath, JSON.stringify(pkg, null, 2))
consola.info('Generated', prettyPath(pkgPath))
consola.success('Ready to run `wrangler publish`')
}
}
}) })