-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
index.ts
40 lines (38 loc) · 916 Bytes
/
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
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,
assetPrefix,
}: {
rootDirectory: string
customAppFile: string | null
isDevelopment: boolean
isServer: boolean
hasSupportCss: boolean
assetPrefix: string
}
): Promise<webpack.Configuration> {
const ctx: ConfigurationContext = {
rootDirectory,
customAppFile,
isDevelopment,
isProduction: !isDevelopment,
isServer,
isClient: !isServer,
assetPrefix: assetPrefix
? assetPrefix.endsWith('/')
? assetPrefix.slice(0, -1)
: assetPrefix
: '',
}
const fn = pipe(base(ctx), css(hasSupportCss, ctx))
return fn(config)
}