forked from vercel/next.js
/
index.ts
48 lines (46 loc) · 1.11 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import webpack from 'webpack'
import { NextConfig } from '../../../next-server/server/config'
import { base } from './blocks/base'
import { css } from './blocks/css'
import { ConfigurationContext, pipe } from './utils'
export async function build(
config: webpack.Configuration,
{
rootDirectory,
customAppFile,
isDevelopment,
isServer,
assetPrefix,
sassOptions,
productionBrowserSourceMaps,
future,
}: {
rootDirectory: string
customAppFile: string | null
isDevelopment: boolean
isServer: boolean
assetPrefix: string
sassOptions: any
productionBrowserSourceMaps: boolean
future: NextConfig['future']
}
): Promise<webpack.Configuration> {
const ctx: ConfigurationContext = {
rootDirectory,
customAppFile,
isDevelopment,
isProduction: !isDevelopment,
isServer,
isClient: !isServer,
assetPrefix: assetPrefix
? assetPrefix.endsWith('/')
? assetPrefix.slice(0, -1)
: assetPrefix
: '',
sassOptions,
productionBrowserSourceMaps,
future,
}
const fn = pipe(base(ctx), css(ctx))
return fn(config)
}