1 | import { ProjectOptions } from '@vue/cli-service'
|
2 | import ChainableWebpackConfig from 'webpack-chain'
|
3 | import * as HtmlWebpackPlugin from 'html-webpack-plugin'
|
4 | import * as WebpackNotifierPlugin from 'webpack-notifier'
|
5 |
|
6 | import {
|
7 | WebpackPluginFunction,
|
8 | WebpackPluginInstance,
|
9 | } from 'webpack/declarations/WebpackOptions'
|
10 |
|
11 |
|
12 | export interface PreprocessConfig {
|
13 | mpa?: boolean
|
14 | moduleEntry?: string
|
15 | moduleRoot?: string
|
16 | htmlTemplate?: string
|
17 | moduleFilter?: string
|
18 | routeExtensions?: string
|
19 | routerViews?: string
|
20 | kebabCasePath?: boolean
|
21 | codeSplitting?: boolean
|
22 | codeSplittingExclude?: string
|
23 | appPlugins?: string
|
24 | appUseVuex?: boolean
|
25 | appUseRouter?: boolean
|
26 | appNestedRoutes?: 'auto' | 'manual' | 'none'
|
27 | appRouterMode?: 'hash' | 'history'
|
28 | routerParamsSymbol?: string
|
29 | routerViewSymbol?: string
|
30 | routerMapProps?: 'all' | 'params' | 'query' | 'none'
|
31 | rootAppPath?: string
|
32 | moduleRouterName?: string
|
33 | moduleStoreName?: string
|
34 | }
|
35 |
|
36 |
|
37 | export type CopyOptions = { [from: string]: string } | { from: string; to: string }[]
|
38 |
|
39 |
|
40 | export type CompressTaskOptions = { name?: string; dot?: boolean; copy?: CopyOptions }
|
41 | export type CompressOptions =
|
42 | | boolean
|
43 | | string
|
44 | | CompressTaskOptions
|
45 | | CompressTaskOptions[]
|
46 |
|
47 |
|
48 | export type DefineOptions = {
|
49 | [env: string]: string | boolean | number
|
50 | }
|
51 |
|
52 |
|
53 | export type DllOptions = boolean | { [bundleName: string]: string | string[] }
|
54 |
|
55 |
|
56 | export type EjectOptions = boolean | string | string[]
|
57 |
|
58 |
|
59 | export type HTMLOptions = { [pageName: string]: HtmlWebpackPlugin.Options }
|
60 |
|
61 |
|
62 | export type WebsocketMockOptions = {
|
63 | context?: ''
|
64 | debugContext?: ''
|
65 | channel?: string | string[]
|
66 | client?: string
|
67 | port?: number
|
68 | }
|
69 | export type MockOptions =
|
70 | | boolean
|
71 | | {
|
72 | http?: boolean
|
73 | path?: string
|
74 | delay?: number
|
75 | defaultDelay?: number
|
76 | init?: boolean
|
77 | locate?: boolean
|
78 | defaultDisabled?: boolean
|
79 | pathHandler?: (path: string) => string | void
|
80 | exclude?: string | ((path: string) => boolean) | RegExp
|
81 | data: { input?: string; output?: string }
|
82 | ws: boolean | WebsocketMockOptions
|
83 | }
|
84 |
|
85 | // sprites
|
86 | export type SpritesOptions =
|
87 | | boolean
|
88 | | {
|
89 | iconLibClass?: string
|
90 | classPrefix?: string
|
91 | kebabCaseName?: string
|
92 | src?: { cwd?: string; glob?: string; options?: object }
|
93 | target?: { image?: string; css?: string }
|
94 | templateHandler?: (data: object) => string
|
95 | spritesmithOptions?: object
|
96 | retina?: object
|
97 | }
|
98 |
|
99 |
|
100 | export type SvgIconConfig = {
|
101 | src?: string
|
102 | prefix?: string
|
103 | kebabCaseName?: string
|
104 | }
|
105 | export type SvgIconOptions = boolean | string | SvgIconConfig | SvgIconConfig[]
|
106 |
|
107 |
|
108 | export type ThemeOption = {
|
109 | patterns: string | string[]
|
110 | preProcessor?: 'sass' | 'scss' | 'stylus' | 'less'
|
111 | injector?: 'prepend' | 'append' | ((source, resources) => string)
|
112 | globOptions?: object
|
113 | resolveUrl?: boolean
|
114 | }
|
115 | export type ThemeOptions = string | string[] | ThemeOption | ThemeOption[]
|
116 |
|
117 | // unused
|
118 | export type UnusedOptions =
|
119 | | boolean
|
120 | | {
|
121 | patterns: string[]
|
122 | failOnUnused?: boolean
|
123 | globOptions?: { ignore?: string; cwd?: string }
|
124 | }
|
125 |
|
126 | // watch
|
127 | export type WatchOptions = {
|
128 | done?: () => void | Promise<any>
|
129 | watchRun?: () => void | Promise<any>
|
130 | invalid?: () => void
|
131 | }
|
132 |
|
133 |
|
134 | export interface ServiceConfig {
|
135 | copy: CopyOptions
|
136 | compress: CompressOptions
|
137 | define: DefineOptions
|
138 | dll: DllOptions
|
139 | eject: EjectOptions
|
140 | html: HTMLOptions
|
141 | mock: MockOptions
|
142 | notifier: WebpackNotifierPlugin.Options
|
143 | removeConsole: boolean | { exclude: string[] }
|
144 | removeDebugger: boolean
|
145 | sprites: SpritesOptions
|
146 | svgIcon: SvgIconOptions
|
147 | theme: ThemeOptions
|
148 | timeCost: boolean
|
149 | unused: UnusedOptions
|
150 | watch: WatchOptions
|
151 | [service: string]: any
|
152 | }
|
153 |
|
154 |
|
155 | export interface ServiceContext {
|
156 | api: object
|
157 | plugin: { use: () => {} }
|
158 | config: ChainableWebpackConfig
|
159 | isDev: boolean
|
160 | isDevelopment: boolean
|
161 | isTest: boolean
|
162 | isProd: boolean
|
163 | isProduction: boolean
|
164 | env: object
|
165 | args: object
|
166 | rawArgv: string[]
|
167 | command: string
|
168 | commandList: string[]
|
169 | modernApp: boolean
|
170 | modernBuild: boolean
|
171 | merge: () => any
|
172 | registerShutdown: () => any
|
173 | watch: () => any
|
174 | }
|
175 |
|
176 | export interface UTBuilder extends ProjectOptions {
|
177 | pluginOptions: {
|
178 | htmlTemplate?: string
|
179 | moduleEntry?: string
|
180 | pageNameMap?: object
|
181 | preprocess?: PreprocessConfig
|
182 | services?: ServiceConfig
|
183 | registerService?: {
|
184 | [key: string]: {
|
185 | (context: ServiceContext, options: any, projectOptions: ProjectOptions): any
|
186 | }
|
187 | }
|
188 | registerPlugin?: {
|
189 | [plugin: string]: WebpackPluginFunction | WebpackPluginInstance
|
190 | }
|
191 | [plugin: string]: any
|
192 | }
|
193 | }
|
194 |
|
195 | export default UTBuilder
|