rsnext/packages/next/build/webpack/config/utils.ts
Jiachi Liu 03eb4b1d61
Bypass empty pages folder for layouts (#40132)
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
2022-09-03 00:13:47 +00:00

36 lines
864 B
TypeScript

import type { webpack } from 'next/dist/compiled/webpack/webpack'
import type { NextConfigComplete } from '../../../server/config-shared'
export type ConfigurationContext = {
supportedBrowsers: string[] | undefined
rootDirectory: string
customAppFile: RegExp | undefined
isDevelopment: boolean
isProduction: boolean
isServer: boolean
isClient: boolean
isEdgeRuntime: boolean
targetWeb: boolean
assetPrefix: string
sassOptions: any
productionBrowserSourceMaps: boolean
future: NextConfigComplete['future']
experimental: NextConfigComplete['experimental']
}
export type ConfigurationFn = (
a: webpack.Configuration
) => webpack.Configuration
export const pipe =
<R>(...fns: Array<(a: R) => R | Promise<R>>) =>
(param: R) =>
fns.reduce(
async (result: R | Promise<R>, next) => next(await result),
param
)