/
build.d.ts
186 lines (173 loc) · 6.36 KB
/
build.d.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* NuxtOptionsBuild
* Documentation: https://nuxtjs.org/api/configuration-build
*/
import type { IncomingMessage, ServerResponse } from 'http'
import type { TransformOptions, PluginItem } from '@babel/core'
import type { Options as AutoprefixerOptions } from 'autoprefixer'
import type { Options as FileLoaderOptions } from 'file-loader'
import type { Options as HtmlMinifierOptions } from 'html-minifier'
import type { Options as OptimizeCssAssetsWebpackPluginOptions } from 'optimize-css-assets-webpack-plugin'
import type { Plugin as PostcssPlugin } from 'postcss'
import type { Options as PugOptions } from 'pug'
import type { TerserPluginOptions } from 'terser-webpack-plugin'
import type { VueLoaderOptions } from 'vue-loader'
import type {
Configuration as WebpackConfiguration,
Loader as WebpackLoader,
loader as WebpackLoaderNamespace,
Options as WebpackOptions,
Plugin as WebpackPlugin
} from 'webpack'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import type { Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware'
import type { MiddlewareOptions as WebpackHotMiddlewareOptions, ClientOptions as WebpackHotMiddlewareClientOptions } from 'webpack-hot-middleware'
import type { Options as SassOptions } from '../lib/sass-loader'
type CssLoaderUrlFunction = (url: string, resourcePath: string) => boolean
type CssLoaderImportFunction = (url: string, media: string, resourcePath: string) => boolean
type CssLoaderMode = 'global' | 'local' | 'pure'
interface CssLoaderModulesOptions {
compileType?: 'module' | 'icss',
mode?: CssLoaderMode,
auto?: Boolean | RegExp | ((resourcePath: string) => boolean),
exportGlobals?: boolean,
localIdentName?: string,
context?: string,
localIdentHashPrefix?: string,
namedExport?: boolean,
exportLocalsConvention?: 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly',
exportOnlyLocals?: boolean,
}
interface CssLoaderOptions {
url?: boolean | CssLoaderUrlFunction
import?: boolean | CssLoaderImportFunction
modules?: boolean | CssLoaderMode | CssLoaderModulesOptions
sourceMap?: boolean
importLoaders?: number
esModule?: boolean
}
interface UrlLoaderOptions {
esModule?: boolean
fallback?: WebpackLoader
limit?: boolean | number | string
mimetype?: string
}
interface NuxtOptionsLoaders {
css?: CssLoaderOptions
cssModules?: CssLoaderOptions
file?: FileLoaderOptions
fontUrl?: UrlLoaderOptions
imgUrl?: UrlLoaderOptions
less?: Less.Options
pugPlain?: PugOptions
sass?: SassOptions
scss?: SassOptions
stylus?: any // TBD
vue?: VueLoaderOptions
vueStyle?: {
manualInject?: boolean
ssrId?: boolean
shadowMode?: boolean
}
}
interface NuxtWebpackEnv {
isClient: boolean
isDev: boolean
isLegacy: boolean
isModern: boolean
isServer: boolean
}
interface NuxtBabelPresetEnv {
envName: 'client' | 'modern' | 'server'
}
interface NuxtBabelOptions extends Pick<TransformOptions, Exclude<keyof TransformOptions, 'presets' | 'plugins'>> {
cacheCompression?: boolean
cacheDirectory?: boolean
cacheIdentifier?: string
customize?: string | null
// eslint-disable-next-line @typescript-eslint/ban-types
presets?: ((env: NuxtBabelPresetEnv & NuxtWebpackEnv, defaultPreset: [string, object]) => PluginItem[] | void) | PluginItem[] | null
plugins?: ((env: NuxtBabelPresetEnv & NuxtWebpackEnv) => NonNullable<TransformOptions['plugins']>) | TransformOptions['plugins']
}
interface Warning {
message: string
name: string
}
interface PostcssOrderPresetFunctions {
cssnanoLast: (names: string[]) => string[]
presetEnvAndCssnanoLast: (names: string[]) => string[]
presetEnvLast: (names: string[]) => string[]
}
type PostcssOrderPreset = keyof PostcssOrderPresetFunctions
interface PostcssVariableMap {
customMedia: Record<string, string>
customProperties: Record<string, string>
customSelectors: Record<string, string>
environmentVariables?: Record<string, string>
}
interface PostcssConfiguration {
order?: PostcssOrderPreset | string[] | ((names: string[], presets: PostcssOrderPresetFunctions) => string[])
plugins?: {
[key: string]: false | { [key: string]: any }
} | ((loader: WebpackLoaderNamespace.LoaderContext) => PostcssPlugin[]) | Array<[string | PostcssPlugin, any] | string | PostcssPlugin>
readonly preset?: {
autoprefixer?: false | AutoprefixerOptions
browsers?: string
exportTo?: string | string[] | Partial<PostcssVariableMap> | ((map: PostcssVariableMap) => Partial<PostcssVariableMap>)
features?: {
[key: string]: boolean | { [key: string]: any }
}
importFrom?: string | string[] | Partial<PostcssVariableMap> | (() => Partial<PostcssVariableMap>)
insertAfter?: { [key: string]: PostcssPlugin }
insertBefore?: { [key: string]: PostcssPlugin }
preserve?: boolean
stage?: 0 | 1 | 2 | 3 | 4 | false
}
}
export interface NuxtOptionsBuild {
additionalExtensions?: string[]
analyze?: BundleAnalyzerPlugin.Options | boolean
babel?: NuxtBabelOptions
cache?: boolean
corejs?: 'auto' | 2 | 3
crossorigin?: string
cssSourceMap?: boolean
devMiddleware?: WebpackDevMiddlewareOptions<IncomingMessage, ServerResponse>
devtools?: boolean
extend?(
config: WebpackConfiguration,
ctx: {
loaders: NuxtOptionsLoaders
} & NuxtWebpackEnv
): void
extractCSS?: boolean | Record<string, any>
filenames?: { [key in 'app' | 'chunk' | 'css' | 'img' | 'font' | 'video']?: (ctx: NuxtWebpackEnv) => string }
friendlyErrors?: boolean
hardSource?: boolean
hotMiddleware?: WebpackHotMiddlewareOptions & { client?: WebpackHotMiddlewareClientOptions }
html?: { minify: false | HtmlMinifierOptions }
indicator?: boolean
loaders?: NuxtOptionsLoaders
loadingScreen?: boolean | any
optimization?: WebpackOptions.Optimization
optimizeCSS?: OptimizeCssAssetsWebpackPluginOptions | boolean
parallel?: boolean
plugins?: WebpackPlugin[]
postcss?: string[] | boolean | { postcssOptions: PostcssConfiguration | (() => PostcssConfiguration) }
profile?: boolean
publicPath?: string
quiet?: boolean
splitChunks?: {
commons?: boolean
layouts?: boolean
pages?: boolean
}
ssr?: boolean
standalone?: boolean
stats?: WebpackConfiguration['stats']
templates?: any
terser?: TerserPluginOptions | boolean
transpile?: Array<string | RegExp | ((context: NuxtWebpackEnv) => string | RegExp | undefined)>
warningIgnoreFilters?: Array<(warn: Warning) => boolean>
watch?: string[]
}