2021-01-14 02:59:08 +01:00
|
|
|
import { webpack } from 'next/dist/compiled/webpack/webpack'
|
2021-07-20 20:42:29 +02:00
|
|
|
import { NextConfigComplete } from '../../../server/config-shared'
|
2019-12-09 21:08:15 +01:00
|
|
|
import { base } from './blocks/base'
|
|
|
|
import { css } from './blocks/css'
|
2021-09-06 13:41:18 +02:00
|
|
|
import { images } from './blocks/images'
|
2019-12-09 21:08:15 +01:00
|
|
|
import { ConfigurationContext, pipe } from './utils'
|
|
|
|
|
|
|
|
export async function build(
|
|
|
|
config: webpack.Configuration,
|
|
|
|
{
|
|
|
|
rootDirectory,
|
|
|
|
customAppFile,
|
|
|
|
isDevelopment,
|
|
|
|
isServer,
|
2021-10-26 18:50:56 +02:00
|
|
|
webServerRuntime,
|
|
|
|
targetWeb,
|
2020-01-03 18:45:04 +01:00
|
|
|
assetPrefix,
|
2020-03-16 10:55:16 +01:00
|
|
|
sassOptions,
|
2020-05-17 22:30:42 +02:00
|
|
|
productionBrowserSourceMaps,
|
2021-01-11 18:19:56 +01:00
|
|
|
future,
|
2021-10-25 01:54:16 +02:00
|
|
|
experimental,
|
2019-12-09 21:08:15 +01:00
|
|
|
}: {
|
|
|
|
rootDirectory: string
|
2021-08-19 10:12:12 +02:00
|
|
|
customAppFile: RegExp
|
2019-12-09 21:08:15 +01:00
|
|
|
isDevelopment: boolean
|
|
|
|
isServer: boolean
|
2021-10-26 18:50:56 +02:00
|
|
|
webServerRuntime: boolean
|
|
|
|
targetWeb: boolean
|
2020-01-03 18:45:04 +01:00
|
|
|
assetPrefix: string
|
2020-03-16 10:55:16 +01:00
|
|
|
sassOptions: any
|
2020-05-17 22:30:42 +02:00
|
|
|
productionBrowserSourceMaps: boolean
|
2021-07-20 20:42:29 +02:00
|
|
|
future: NextConfigComplete['future']
|
2021-10-25 01:54:16 +02:00
|
|
|
experimental: NextConfigComplete['experimental']
|
2019-12-09 21:08:15 +01:00
|
|
|
}
|
|
|
|
): Promise<webpack.Configuration> {
|
|
|
|
const ctx: ConfigurationContext = {
|
|
|
|
rootDirectory,
|
|
|
|
customAppFile,
|
|
|
|
isDevelopment,
|
|
|
|
isProduction: !isDevelopment,
|
|
|
|
isServer,
|
2021-10-26 18:50:56 +02:00
|
|
|
webServerRuntime,
|
2019-12-09 21:08:15 +01:00
|
|
|
isClient: !isServer,
|
2021-10-26 18:50:56 +02:00
|
|
|
targetWeb,
|
2020-01-03 18:45:04 +01:00
|
|
|
assetPrefix: assetPrefix
|
|
|
|
? assetPrefix.endsWith('/')
|
|
|
|
? assetPrefix.slice(0, -1)
|
|
|
|
: assetPrefix
|
|
|
|
: '',
|
2020-03-16 10:55:16 +01:00
|
|
|
sassOptions,
|
2020-05-17 22:30:42 +02:00
|
|
|
productionBrowserSourceMaps,
|
2021-01-11 18:19:56 +01:00
|
|
|
future,
|
2021-10-25 01:54:16 +02:00
|
|
|
experimental,
|
2019-12-09 21:08:15 +01:00
|
|
|
}
|
|
|
|
|
2021-09-06 13:41:18 +02:00
|
|
|
const fn = pipe(base(ctx), css(ctx), images(ctx))
|
2019-12-09 21:08:15 +01:00
|
|
|
return fn(config)
|
|
|
|
}
|