2019-01-28 12:46:34 +00:00
|
|
|
|
import webpack = require('webpack');
|
|
|
|
|
|
import WebpackDevServer = require('webpack-dev-server');
|
|
|
|
|
|
|
|
|
|
|
|
export interface Urls {
|
|
|
|
|
|
lanUrlForConfig?: string;
|
|
|
|
|
|
lanUrlForTerminal?: string;
|
|
|
|
|
|
localUrlForTerminal: string;
|
|
|
|
|
|
localUrlForBrowser: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Returns a Promise resolving to either `defaultPort` or next available port
|
|
|
|
|
|
* if the user confirms it is okay to do. If the port is taken and the user has
|
|
|
|
|
|
* refused to use another port, or if the terminal is not interactive and can’t
|
|
|
|
|
|
* present user with the choice, resolves to `null`.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function choosePort(host: string, defaultPort: number): Promise<number | null>;
|
|
|
|
|
|
|
2019-05-06 08:10:35 +00:00
|
|
|
|
export interface CreateCompilerOptions {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* The name that will be printed to the terminal.
|
|
|
|
|
|
*/
|
|
|
|
|
|
appName: string;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* The webpack configuration options to be provided to the webpack constructor.
|
|
|
|
|
|
*/
|
|
|
|
|
|
config: webpack.Configuration;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* To provide the `urls` argument, use `prepareUrls()` described below.
|
|
|
|
|
|
*/
|
|
|
|
|
|
urls: Urls;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* If `true`; yarn instructions will be emitted in the terminal instead of npm.
|
|
|
|
|
|
*/
|
|
|
|
|
|
useYarn?: boolean;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Takes the `require('webpack')` entry point.
|
|
|
|
|
|
*/
|
|
|
|
|
|
webpack: typeof webpack;
|
|
|
|
|
|
}
|
|
|
|
|
|
export interface CreateCompilerOptionsTypescript extends CreateCompilerOptions {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Required if useTypeScript is `true`.
|
|
|
|
|
|
* This is useful when running fork-ts-checker-webpack-plugin with `async: true` to
|
|
|
|
|
|
* report errors that are emitted after the webpack build is complete.
|
|
|
|
|
|
*/
|
|
|
|
|
|
devSocket: {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Called when there are build errors.
|
|
|
|
|
|
*/
|
|
|
|
|
|
errors: (errors: string[]) => void;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Called when there are build warnings.
|
|
|
|
|
|
*/
|
|
|
|
|
|
warnings: (warnings: string[]) => void;
|
|
|
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
|
|
|
* If `true`, TypeScript type checking will be enabled.
|
|
|
|
|
|
* Be sure to provide the `devSocket` argument above if this is set to `true`.
|
|
|
|
|
|
*/
|
|
|
|
|
|
useTypeScript: boolean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-28 12:46:34 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Creates a Webpack compiler instance for WebpackDevServer with built-in
|
2019-05-06 08:10:35 +00:00
|
|
|
|
* helpful messages.
|
2019-01-28 12:46:34 +00:00
|
|
|
|
*/
|
2019-05-06 08:10:35 +00:00
|
|
|
|
export function createCompiler(opts: CreateCompilerOptions): webpack.Compiler;
|
|
|
|
|
|
// if the signatures are merged, TS will not enforce that both useTypeScript and devSocket are provided
|
|
|
|
|
|
// tslint:disable-next-line:unified-signatures
|
|
|
|
|
|
export function createCompiler(opts: CreateCompilerOptionsTypescript): webpack.Compiler;
|
2019-01-28 12:46:34 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Creates a WebpackDevServer `proxy` configuration object from the `proxy`
|
|
|
|
|
|
* setting in `package.json`.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function prepareProxy(
|
2019-05-06 08:10:35 +00:00
|
|
|
|
proxySetting: string | undefined,
|
2019-01-28 12:46:34 +00:00
|
|
|
|
appPublicFolder: string,
|
2020-02-13 23:28:54 +00:00
|
|
|
|
servedPathname: string,
|
2019-05-05 08:38:54 +00:00
|
|
|
|
): WebpackDevServer.ProxyConfigArray;
|
2019-01-28 12:46:34 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Returns an object with local and remote URLs for the development server.
|
|
|
|
|
|
* Pass this object to `createCompiler()` described above.
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function prepareUrls(protocol: string, host: string, port: number): Urls;
|