feat(nitro): support esbuild options config (#550)

This commit is contained in:
Xin Du (Clark) 2021-09-22 15:39:54 +01:00 committed by GitHub
parent 317fc55539
commit a137d2e5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import type { StorageOptions } from './rollup/plugins/storage'
import type { AssetOptions } from './rollup/plugins/assets' import type { AssetOptions } from './rollup/plugins/assets'
import type { ServerMiddleware } from './server/middleware' import type { ServerMiddleware } from './server/middleware'
import type { RollupConfig } from './rollup/config' import type { RollupConfig } from './rollup/config'
import type { Options as EsbuildOptions } from './rollup/plugins/esbuild'
export interface NitroHooks { export interface NitroHooks {
'nitro:document': (htmlTemplate: { src: string, contents: string, dst: string, compiled: string }) => void 'nitro:document': (htmlTemplate: { src: string, contents: string, dst: string, compiled: string }) => void
@ -31,6 +32,9 @@ export interface NitroContext {
node: boolean node: boolean
preset: string preset: string
rollupConfig?: RollupConfig rollupConfig?: RollupConfig
esbuild?: {
options?: EsbuildOptions
}
moduleSideEffects: string[] moduleSideEffects: string[]
renderer: string renderer: string
serveStatic: boolean serveStatic: boolean

View File

@ -158,7 +158,8 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
// ESBuild // ESBuild
rollupConfig.plugins.push(esbuild({ rollupConfig.plugins.push(esbuild({
target: 'es2019', target: 'es2019',
sourceMap: true sourceMap: true,
...nitroContext.esbuild?.options
})) }))
// Dynamic Require Support // Dynamic Require Support