1 | /// <reference types="node" />
|
2 | import * as Promise from 'bluebird';
|
3 | import * as events from 'events';
|
4 | import * as webpack from 'webpack';
|
5 | declare type FilePath = string;
|
6 | /**
|
7 | * Configuration object for this Webpack preprocessor
|
8 | */
|
9 | interface PreprocessorOptions {
|
10 | webpackOptions?: webpack.Configuration;
|
11 | watchOptions?: Object;
|
12 | additionalEntries?: string[];
|
13 | }
|
14 | interface FileEvent extends events.EventEmitter {
|
15 | filePath: FilePath;
|
16 | outputPath: string;
|
17 | shouldWatch: boolean;
|
18 | }
|
19 | /**
|
20 | * Cypress asks file preprocessor to bundle the given file
|
21 | * and return the full path to produced bundle.
|
22 | */
|
23 | declare type FilePreprocessor = (file: FileEvent) => Promise<FilePath>;
|
24 | declare type WebpackPreprocessorFn = (options: PreprocessorOptions) => FilePreprocessor;
|
25 | /**
|
26 | * Cypress file preprocessor that can bundle specs
|
27 | * using Webpack.
|
28 | */
|
29 | interface WebpackPreprocessor extends WebpackPreprocessorFn {
|
30 | /**
|
31 | * Default options for Cypress Webpack preprocessor.
|
32 | * You can modify these options then pass to the preprocessor.
|
33 | * @example
|
34 | ```
|
35 | const defaults = webpackPreprocessor.defaultOptions
|
36 | module.exports = (on) => {
|
37 | delete defaults.webpackOptions.module.rules[0].use[0].options.presets
|
38 | on('file:preprocessor', webpackPreprocessor(defaults))
|
39 | }
|
40 | ```
|
41 | *
|
42 | * @type {Omit<PreprocessorOptions, 'additionalEntries'>}
|
43 | * @memberof WebpackPreprocessor
|
44 | */
|
45 | defaultOptions: Omit<PreprocessorOptions, 'additionalEntries'>;
|
46 | }
|
47 | /**
|
48 | * Webpack preprocessor configuration function. Takes configuration object
|
49 | * and returns file preprocessor.
|
50 | * @example
|
51 | ```
|
52 | on('file:preprocessor', webpackPreprocessor(options))
|
53 | ```
|
54 | */
|
55 | declare const preprocessor: WebpackPreprocessor;
|
56 | export = preprocessor;
|