ko
Version:
build & lint library
160 lines (159 loc) • 4.49 kB
TypeScript
import { Pattern } from 'copy-webpack-plugin';
import { Plugin } from 'postcss';
import { IKeys, IOpts } from 'ko-lints';
import { IOpts as AutoPolyfillsWebpackPluginOptions } from '@dtinsight/auto-polyfills-webpack-plugin';
import { ClientConfiguration, Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
export interface IServeConfig extends WebpackDevServerConfiguration {
proxy?: Record<string, any>;
host: string;
port: number;
staticPath?: string;
client?: boolean | ClientConfiguration | undefined;
historyApiFallback?: any;
compilationSuccessInfo?: {
messages: string[];
notes?: string[];
};
}
export type IOptions = {
/**
* The current working directory.
* @param {string}
*/
cwd: string;
/**
* An object mapping module names to file paths or directories.
* @param {Record<string, string>}
*/
alias?: Record<string, string>;
/**
* An array of patterns specifying files to copy to the output directory.
* @param {Pattern[]}
*/
copy?: Pattern[];
/**
* The entry point of the application.
* @param {string}
*/
entry?: string;
/**
* The path to the output directory.
* @param {string}
*/
outputPath?: string;
/**
* The public path of the application.
* @param {string}
*/
publicPath?: string;
/**
* Whether to append a hash to the output file name for cache busting.
* @param {boolean}
*/
hash?: boolean;
/**
* An object mapping module names to global variables.
* @param {Record<string, string>}
*/
externals?: Record<string, string>;
/**
* An array of plugin configurations.
* @param {HookOptions[]}
*/
plugins?: HookOptions[];
/**
* Additional packages/paths to transpile via Babel, on top of ko's defaults.
*
* ko already transpiles these by default (they publish ES2020+ syntax):
* - `immer`
* - `react-grid-layout`
* - `monaco-editor`
* - internal `dt-common` source (`node_modules/dt-common/src/**`)
*
* You do not need to re-list them here. Use this to add your own
* ES2020+ packages that ko doesn't know about. Entries are matched
* as substring against the file path.
*
* @param {string[]}
*/
babelIncludes?: string[];
/**
* The path to the HTML template to use for the application.
* @param {string}
*/
htmlTemplate?: string;
htmlChunks?: 'all' | string[];
/**
* Whether to enable the bundle analyzer plugin.
* @param {boolean}
*/
analyzer?: boolean;
/**
* An array of additional PostCSS plugins to use.
* @param {Plugin[]}
*/
extraPostCSSPlugins?: Plugin[];
/**
* Options to pass to the Less compiler.
* @param {*}
*/
lessOptions?: any;
/**
* A function to dynamically resolve module requests.
* @param {Function}
*/
dynamicResolve?: <T extends any>(request: T) => T;
/**
* Whether to enable the auto-polyfills plugin, or an options object for the plugin.
* @param {string}
*/
autoPolyfills: boolean | AutoPolyfillsWebpackPluginOptions;
/**
* Options for the development server.
* Docs url: https://webpack.js.org/configuration/dev-server/
* @param {IServeConfig}
*/
serve: IServeConfig;
/**
* Experimental features to enable.
* @param {{speedUp?: boolean, minimizer?: boolean, disableLazyImports?: boolean, enableCssModule?: boolean, compress?: any}}
*/
experiment?: {
speedUp?: boolean;
minimizer?: boolean;
disableLazyImports?: boolean;
enableCssModule?: boolean;
compress?: any;
};
/**
* Options for the linter plugins.
* @param {Record<IKeys, Omit<IOpts, 'write'>>}
*/
lints?: Record<IKeys, Omit<IOpts, 'write'>>;
};
export type ICliOptions = {
hash?: boolean;
analyzer?: boolean;
};
export type IWebpackOptions = IOptions & {
isProd: boolean;
} & ICliOptions;
export type HookItem = {
name: string;
fn: Function;
stage?: number;
before?: string;
};
export declare enum ACTION {
ADD = "add",
UPDATE = "update"
}
export declare enum HOOK_KEY_SET {
WEBPACK_PLUGIN = "WebpackPlugin",
MODIFY_WEBPACK = "ModifyWebpack"
}
export type HookOptions = {
key: string;
action: ACTION;
opts: HookItem;
};