03eb4b1d61
Check `pagesDir` to bypass empty pages folder when appDir is enabled * Output empty loadable manifest for now if there's no `pagesDir` * No custom aliases with all page extensions for `/_app`, `_document` if pagesDir is empty, only keep the built-in ones * Check pagesDir in build/dev-server/eslint * Type safe: change arguments of some APIs from optional to required, so that we won't mess up with default arguments
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import type { webpack } from 'next/dist/compiled/webpack/webpack'
|
|
import type { NextConfigComplete } from '../../../server/config-shared'
|
|
|
|
import { base } from './blocks/base'
|
|
import { css } from './blocks/css'
|
|
import { images } from './blocks/images'
|
|
import { ConfigurationContext, pipe } from './utils'
|
|
|
|
export async function build(
|
|
config: webpack.Configuration,
|
|
{
|
|
supportedBrowsers,
|
|
rootDirectory,
|
|
customAppFile,
|
|
isDevelopment,
|
|
isServer,
|
|
isEdgeRuntime,
|
|
targetWeb,
|
|
assetPrefix,
|
|
sassOptions,
|
|
productionBrowserSourceMaps,
|
|
future,
|
|
experimental,
|
|
disableStaticImages,
|
|
}: {
|
|
supportedBrowsers: string[] | undefined
|
|
rootDirectory: string
|
|
customAppFile: RegExp | undefined
|
|
isDevelopment: boolean
|
|
isServer: boolean
|
|
isEdgeRuntime: boolean
|
|
targetWeb: boolean
|
|
assetPrefix: string
|
|
sassOptions: any
|
|
productionBrowserSourceMaps: boolean
|
|
future: NextConfigComplete['future']
|
|
experimental: NextConfigComplete['experimental']
|
|
disableStaticImages: NextConfigComplete['disableStaticImages']
|
|
}
|
|
): Promise<webpack.Configuration> {
|
|
const ctx: ConfigurationContext = {
|
|
supportedBrowsers,
|
|
rootDirectory,
|
|
customAppFile,
|
|
isDevelopment,
|
|
isProduction: !isDevelopment,
|
|
isServer,
|
|
isEdgeRuntime,
|
|
isClient: !isServer,
|
|
targetWeb,
|
|
assetPrefix: assetPrefix
|
|
? assetPrefix.endsWith('/')
|
|
? assetPrefix.slice(0, -1)
|
|
: assetPrefix
|
|
: '',
|
|
sassOptions,
|
|
productionBrowserSourceMaps,
|
|
future,
|
|
experimental,
|
|
}
|
|
|
|
let fns = [base(ctx), css(ctx)]
|
|
if (!disableStaticImages) {
|
|
fns.push(images(ctx))
|
|
}
|
|
const fn = pipe(...fns)
|
|
return fn(config)
|
|
}
|