mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
feat: detect target
Co-authored-by: Sebasiten Chopin <seb@nuxtjs.com>
This commit is contained in:
parent
5fdc6ccfb6
commit
ddccc9cb78
@ -1,7 +1,7 @@
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import defu from 'defu'
|
import defu from 'defu'
|
||||||
import { NuxtOptions } from '@nuxt/types'
|
import { NuxtOptions } from '@nuxt/types'
|
||||||
import { tryImport, LIB_DIR, resolvePath } from './utils'
|
import { tryImport, LIB_DIR, resolvePath, detectTarget } from './utils'
|
||||||
|
|
||||||
export type UnresolvedPath = string | ((SLSOptions) => string)
|
export type UnresolvedPath = string | ((SLSOptions) => string)
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ export function getoptions (nuxtOptions: NuxtOptions): SLSOptions {
|
|||||||
targetDir: null
|
targetDir: null
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = process.env.NUXT_SLS_TARGET || nuxtOptions.serverless.target || 'node'
|
let target = process.env.NUXT_SLS_TARGET || nuxtOptions.serverless.target || detectTarget()
|
||||||
if (typeof target === 'function') {
|
if (typeof target === 'function') {
|
||||||
target = target(nuxtOptions)
|
target = target(nuxtOptions)
|
||||||
}
|
}
|
||||||
|
@ -42,5 +42,17 @@ export function resolvePath (options: SLSOptions, path: UnresolvedPath, resolveB
|
|||||||
return resolve(resolveBase, typeof path === 'string' ? path : path(options))
|
return resolve(resolveBase, typeof path === 'string' ? path : path(options))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function detectTarget () {
|
||||||
|
if (process.env.NETLIFY) {
|
||||||
|
return 'netlify'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.VERCEL_URL) {
|
||||||
|
return 'vercel'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'node'
|
||||||
|
}
|
||||||
|
|
||||||
export const LIB_DIR = resolve(__dirname, '../lib')
|
export const LIB_DIR = resolve(__dirname, '../lib')
|
||||||
export const RUNTIME_DIR = resolve(LIB_DIR, 'runtime')
|
export const RUNTIME_DIR = resolve(LIB_DIR, 'runtime')
|
||||||
|
Loading…
Reference in New Issue
Block a user