1 | import minimist = require('minimist')
|
2 | import ChainableConfig = require('webpack-chain')
|
3 | import webpack = require('webpack')
|
4 | import WebpackDevServer = require('webpack-dev-server')
|
5 | import express = require('express') // @types/webpack-dev-server depends on @types/express
|
6 | import { ProjectOptions, ConfigFunction } from './ProjectOptions'
|
7 |
|
8 | type RegisterCommandFn = (args: minimist.ParsedArgs, rawArgv: string[]) => any
|
9 |
|
10 | type RegisterCommandOpts = Partial<{
|
11 | description: string
|
12 | usage: string
|
13 | options: {
|
14 | [flags: string]: string
|
15 | }
|
16 | details: string
|
17 | }>
|
18 |
|
19 | type WebpackChainFn = (chainableConfig: ChainableConfig) => void
|
20 |
|
21 | type webpackRawConfigFn = ((config: webpack.Configuration) => webpack.Configuration | void) | webpack.Configuration
|
22 |
|
23 | type DevServerConfigFn = (app: express.Application, server: WebpackDevServer) => void
|
24 |
|
25 | interface CacheConfig {
|
26 | cacheDirectory: string
|
27 | cacheIdentifier: string
|
28 | }
|
29 | declare class PluginAPI {
|
30 | id: string
|
31 |
|
32 | service: any
|
33 |
|
34 | readonly version: string
|
35 |
|
36 | assertVersion(range: number | string): void
|
37 |
|
38 | /**
|
39 | * Current working directory.
|
40 | */
|
41 | getCwd(): string
|
42 |
|
43 | /**
|
44 | * Resolve path for a project.
|
45 | *
|
46 | * @param _path - Relative path from project root
|
47 | * @return The resolved absolute path.
|
48 | */
|
49 | resolve(_path: string): string
|
50 |
|
51 | /**
|
52 | * Check if the project has a given plugin.
|
53 | *
|
54 | * @param id - Plugin id, can omit the (@vue/|vue-|@scope/vue)-cli-plugin- prefix
|
55 | * @return `boolean`
|
56 | */
|
57 | hasPlugin(id: string): boolean
|
58 |
|
59 | /**
|
60 | * Register a command that will become available as `vue-cli-service [name]`.
|
61 | *
|
62 | * @param name
|
63 | * @param [opts]
|
64 | * @param fn
|
65 | */
|
66 | registerCommand(name: string, fn: RegisterCommandFn): void
|
67 | registerCommand(name: string, opts: RegisterCommandOpts, fn: RegisterCommandFn): void
|
68 |
|
69 | /**
|
70 | * Register a function that will receive a chainable webpack config
|
71 | * the function is lazy and won't be called until `resolveWebpackConfig` is
|
72 | * called
|
73 | *
|
74 | * @param fn
|
75 | */
|
76 | chainWebpack(fn: WebpackChainFn): void
|
77 |
|
78 | /**
|
79 | * Register
|
80 | * - a webpack configuration object that will be merged into the config
|
81 | * OR
|
82 | * - a function that will receive the raw webpack config.
|
83 | * the function can either mutate the config directly or return an object
|
84 | * that will be merged into the config.
|
85 | *
|
86 | * @param fn
|
87 | */
|
88 | configureWebpack(fn: webpackRawConfigFn): void
|
89 |
|
90 | /**
|
91 | * Register a dev serve config function. It will receive the express `app`
|
92 | * instance of the dev server.
|
93 | *
|
94 | * @param fn
|
95 | */
|
96 | configureDevServer(fn: DevServerConfigFn): void
|
97 |
|
98 | /**
|
99 | * Resolve the final raw webpack config, that will be passed to webpack.
|
100 | *
|
101 | * @param [chainableConfig]
|
102 | * @return Raw webpack config.
|
103 | */
|
104 | resolveWebpackConfig(chainableConfig?: ChainableConfig): webpack.Configuration
|
105 |
|
106 | /**
|
107 | * Resolve an intermediate chainable webpack config instance, which can be
|
108 | * further tweaked before generating the final raw webpack config.
|
109 | * You can call this multiple times to generate different branches of the
|
110 | * base webpack config.
|
111 | * See https://github.com/mozilla-neutrino/webpack-chain
|
112 | *
|
113 | * @return ChainableWebpackConfig
|
114 | */
|
115 | resolveChainableWebpackConfig(): ChainableConfig
|
116 |
|
117 | /**
|
118 | * Generate a cache identifier from a number of variables
|
119 | */
|
120 | genCacheConfig(id: string, partialIdentifier: any, configFiles?: string | string[]): CacheConfig
|
121 | }
|
122 |
|
123 | /**
|
124 | * Service plugin serves for modifying webpack config,
|
125 | * creating new vue-cli service commands or changing existing commands
|
126 | *
|
127 | * @param api - A PluginAPI instance
|
128 | * @param options - An object containing project local options specified in vue.config.js,
|
129 | * or in the "vue" field in package.json.
|
130 | */
|
131 | type ServicePlugin = (
|
132 | api: PluginAPI,
|
133 | options: ProjectOptions
|
134 | ) => any
|
135 |
|
136 | export { ProjectOptions, ServicePlugin, PluginAPI }
|
137 | type UserConfig = ProjectOptions | ConfigFunction
|
138 | export function defineConfig(config: UserConfig): UserConfig
|
139 |
|
\ | No newline at end of file |