forked from vercel/next.js
/
index.ts
45 lines (43 loc) · 1.03 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
import webpack from 'webpack'
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,
hasSupportCss,
hasSupportScss,
assetPrefix,
scssIncludePaths,
}: {
rootDirectory: string
customAppFile: string | null
isDevelopment: boolean
isServer: boolean
hasSupportCss: boolean
hasSupportScss: boolean
assetPrefix: string
scssIncludePaths: string[]
}
): Promise<webpack.Configuration> {
const ctx: ConfigurationContext = {
rootDirectory,
customAppFile,
isDevelopment,
isProduction: !isDevelopment,
isServer,
isClient: !isServer,
assetPrefix: assetPrefix
? assetPrefix.endsWith('/')
? assetPrefix.slice(0, -1)
: assetPrefix
: '',
scssIncludePaths,
}
const fn = pipe(base(ctx), css(hasSupportCss, hasSupportScss, ctx))
return fn(config)
}