@cypress/webpack-dev-server 1.8.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +47 -81
  3. package/dist/CypressCTWebpackPlugin.d.ts +15 -0
  4. package/dist/CypressCTWebpackPlugin.js +103 -0
  5. package/dist/aut-runner.js +1 -0
  6. package/dist/constants.d.ts +1 -0
  7. package/dist/constants.js +9 -0
  8. package/dist/createWebpackDevServer.d.ts +26 -0
  9. package/dist/createWebpackDevServer.js +49 -0
  10. package/dist/devServer.d.ts +35 -0
  11. package/dist/devServer.js +103 -0
  12. package/dist/helpers/createReactAppHandler.d.ts +8 -0
  13. package/dist/helpers/createReactAppHandler.js +300 -0
  14. package/dist/helpers/nextHandler.d.ts +2 -0
  15. package/dist/helpers/nextHandler.js +197 -0
  16. package/dist/helpers/nuxtHandler.d.ts +2 -0
  17. package/dist/helpers/nuxtHandler.js +27 -0
  18. package/dist/helpers/sourceRelativeWebpackModules.d.ts +46 -0
  19. package/dist/helpers/sourceRelativeWebpackModules.js +197 -0
  20. package/dist/helpers/vueCliHandler.d.ts +2 -0
  21. package/dist/helpers/vueCliHandler.js +23 -0
  22. package/dist/index.d.ts +3 -15
  23. package/dist/index.js +4 -63
  24. package/dist/loader.d.ts +1 -3
  25. package/dist/loader.js +8 -28
  26. package/dist/makeDefaultWebpackConfig.d.ts +1 -0
  27. package/dist/makeDefaultWebpackConfig.js +48 -0
  28. package/dist/makeWebpackConfig.d.ts +6 -16
  29. package/dist/makeWebpackConfig.js +120 -93
  30. package/dist/measureWebpackPerformance.d.ts +1 -2
  31. package/dist/measureWebpackPerformance.js +10 -8
  32. package/package.json +34 -26
  33. package/dist/plugin.d.ts +0 -45
  34. package/dist/plugin.js +0 -84
  35. package/dist/startServer.d.ts +0 -13
  36. package/dist/startServer.js +0 -75
  37. package/dist/webpack.config.d.ts +0 -2
  38. package/dist/webpack.config.js +0 -24
  39. package/dist/webpackDevServerFacts.d.ts +0 -6
  40. package/dist/webpackDevServerFacts.js +0 -19
  41. package/index-template.html +0 -12
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restoreLoadHook = exports.getMajorVersion = exports.sourceDefaultWebpackDependencies = exports.sourceHtmlWebpackPlugin = exports.sourceWebpackDevServer = exports.sourceWebpack = exports.sourceFramework = exports.cypressWebpackPath = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const module_1 = (0, tslib_1.__importDefault)(require("module"));
6
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
7
+ const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
8
+ const debug = (0, debug_1.default)('cypress:webpack-dev-server:sourceRelativeWebpackModules');
9
+ const originalModuleLoad = module_1.default._load;
10
+ const originalModuleResolveFilename = module_1.default._resolveFilename;
11
+ // We ship webpack@4 as part of '@cypress/webpack-batteries-included-preprocessor'. The path to this module
12
+ // serves as our fallback.
13
+ const cypressWebpackPath = (config) => {
14
+ return require.resolve('@cypress/webpack-batteries-included-preprocessor', {
15
+ paths: [config.cypressConfig.cypressBinaryRoot],
16
+ });
17
+ };
18
+ exports.cypressWebpackPath = cypressWebpackPath;
19
+ // Source the users framework from the provided projectRoot. The framework, if available, will server
20
+ // as the resolve base for webpack dependency resolution.
21
+ function sourceFramework(config) {
22
+ debug('Framework: Attempting to source framework for %s', config.cypressConfig.projectRoot);
23
+ if (!config.framework) {
24
+ debug('Framework: No framework provided');
25
+ return null;
26
+ }
27
+ const framework = {};
28
+ try {
29
+ const frameworkJsonPath = require.resolve(`${config.framework}/package.json`, {
30
+ paths: [config.cypressConfig.projectRoot],
31
+ });
32
+ const frameworkPathRoot = path_1.default.dirname(frameworkJsonPath);
33
+ // Want to make sure we're sourcing this from the user's code. Otherwise we can
34
+ // warn and tell them they don't have their dependencies installed
35
+ framework.importPath = frameworkPathRoot;
36
+ framework.packageJson = require(frameworkJsonPath);
37
+ debug('Framework: Successfully sourced framework - %o', framework);
38
+ return framework;
39
+ }
40
+ catch (e) {
41
+ debug('Framework: Failed to source framework - %s', e);
42
+ // TODO
43
+ return null;
44
+ }
45
+ }
46
+ exports.sourceFramework = sourceFramework;
47
+ // Source the webpack module from the provided framework or projectRoot. We override the module resolution
48
+ // so that other packages that import webpack resolve to the version we found.
49
+ // If none is found, we fallback to the bundled version in '@cypress/webpack-batteries-included-preprocessor'.
50
+ function sourceWebpack(config, framework) {
51
+ var _a;
52
+ const searchRoot = (_a = framework === null || framework === void 0 ? void 0 : framework.importPath) !== null && _a !== void 0 ? _a : config.cypressConfig.projectRoot;
53
+ debug('Webpack: Attempting to source webpack from %s', searchRoot);
54
+ const webpack = {};
55
+ let webpackJsonPath;
56
+ try {
57
+ webpackJsonPath = require.resolve('webpack/package.json', {
58
+ paths: [searchRoot],
59
+ });
60
+ }
61
+ catch (e) {
62
+ if (e.code !== 'MODULE_NOT_FOUND') {
63
+ debug('Webpack: Failed to source webpack - %s', e);
64
+ throw e;
65
+ }
66
+ debug('Webpack: Falling back to bundled version');
67
+ webpackJsonPath = require.resolve('webpack/package.json', {
68
+ paths: [(0, exports.cypressWebpackPath)(config)],
69
+ });
70
+ }
71
+ webpack.importPath = path_1.default.dirname(webpackJsonPath);
72
+ webpack.packageJson = require(webpackJsonPath);
73
+ webpack.module = require(webpack.importPath);
74
+ webpack.majorVersion = getMajorVersion(webpack.packageJson, [4, 5]);
75
+ debug('Webpack: Successfully sourced webpack - %o', webpack);
76
+ module_1.default._load = function (request, parent, isMain) {
77
+ if (request === 'webpack' || request.startsWith('webpack/')) {
78
+ const resolvePath = require.resolve(request, {
79
+ paths: [webpack.importPath],
80
+ });
81
+ debug('Webpack: Module._load resolvePath - %s', resolvePath);
82
+ return originalModuleLoad(resolvePath, parent, isMain);
83
+ }
84
+ return originalModuleLoad(request, parent, isMain);
85
+ };
86
+ module_1.default._resolveFilename = function (request, parent, isMain, options) {
87
+ if (request === 'webpack' || request.startsWith('webpack/') && !(options === null || options === void 0 ? void 0 : options.paths)) {
88
+ const resolveFilename = originalModuleResolveFilename(request, parent, isMain, {
89
+ paths: [webpack.importPath],
90
+ });
91
+ debug('Webpack: Module._resolveFilename resolveFilename - %s', resolveFilename);
92
+ return resolveFilename;
93
+ }
94
+ return originalModuleResolveFilename(request, parent, isMain, options);
95
+ };
96
+ return webpack;
97
+ }
98
+ exports.sourceWebpack = sourceWebpack;
99
+ // Source the webpack-dev-server module from the provided framework or projectRoot.
100
+ // If none is found, we fallback to the version bundled with this package.
101
+ function sourceWebpackDevServer(config, framework) {
102
+ var _a;
103
+ const searchRoot = (_a = framework === null || framework === void 0 ? void 0 : framework.importPath) !== null && _a !== void 0 ? _a : config.cypressConfig.projectRoot;
104
+ debug('WebpackDevServer: Attempting to source webpack-dev-server from %s', searchRoot);
105
+ const webpackDevServer = {};
106
+ let webpackDevServerJsonPath;
107
+ try {
108
+ webpackDevServerJsonPath = require.resolve('webpack-dev-server/package.json', {
109
+ paths: [searchRoot],
110
+ });
111
+ }
112
+ catch (e) {
113
+ if (e.code !== 'MODULE_NOT_FOUND') {
114
+ debug('WebpackDevServer: Failed to source webpack-dev-server - %s', e);
115
+ throw e;
116
+ }
117
+ debug('WebpackDevServer: Falling back to bundled version');
118
+ webpackDevServerJsonPath = require.resolve('webpack-dev-server/package.json', {
119
+ paths: [__dirname],
120
+ });
121
+ }
122
+ webpackDevServer.importPath = path_1.default.dirname(webpackDevServerJsonPath);
123
+ webpackDevServer.packageJson = require(webpackDevServerJsonPath);
124
+ webpackDevServer.module = require(webpackDevServer.importPath);
125
+ webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [3, 4]);
126
+ debug('WebpackDevServer: Successfully sourced webpack-dev-server - %o', webpackDevServer);
127
+ return webpackDevServer;
128
+ }
129
+ exports.sourceWebpackDevServer = sourceWebpackDevServer;
130
+ // Source the html-webpack-plugin module from the provided framework or projectRoot.
131
+ // If none is found, we fallback to the version bundled with this package dependent on the major version of webpack.
132
+ // We ship both v4 and v5 of 'html-webpack-plugin' by aliasing the package with the major version (check package.json).
133
+ function sourceHtmlWebpackPlugin(config, framework, webpack) {
134
+ var _a;
135
+ const searchRoot = (_a = framework === null || framework === void 0 ? void 0 : framework.importPath) !== null && _a !== void 0 ? _a : config.cypressConfig.projectRoot;
136
+ debug('HtmlWebpackPlugin: Attempting to source html-webpack-plugin from %s', searchRoot);
137
+ const htmlWebpackPlugin = {};
138
+ let htmlWebpackPluginJsonPath;
139
+ try {
140
+ htmlWebpackPluginJsonPath = require.resolve('html-webpack-plugin/package.json', {
141
+ paths: [searchRoot],
142
+ });
143
+ htmlWebpackPlugin.packageJson = require(htmlWebpackPluginJsonPath);
144
+ // Check that they're not using v3 of html-webpack-plugin. Since we should be the only consumer of it,
145
+ // we shouldn't be concerned with using our own copy if they've shipped w/ an earlier version
146
+ htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [4, 5]);
147
+ }
148
+ catch (e) {
149
+ const err = e;
150
+ if (err.code !== 'MODULE_NOT_FOUND' && !err.message.includes('Unexpected major version')) {
151
+ debug('HtmlWebpackPlugin: Failed to source html-webpack-plugin - %s', e);
152
+ throw e;
153
+ }
154
+ const htmlWebpack = `html-webpack-plugin-${webpack.majorVersion}`;
155
+ debug('HtmlWebpackPlugin: Falling back to bundled version %s', htmlWebpack);
156
+ htmlWebpackPluginJsonPath = require.resolve(`${htmlWebpack}/package.json`, {
157
+ paths: [
158
+ __dirname,
159
+ ],
160
+ });
161
+ }
162
+ htmlWebpackPlugin.importPath = path_1.default.dirname(htmlWebpackPluginJsonPath),
163
+ htmlWebpackPlugin.packageJson = require(htmlWebpackPluginJsonPath),
164
+ htmlWebpackPlugin.module = require(htmlWebpackPlugin.importPath),
165
+ htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [4, 5]);
166
+ debug('HtmlWebpackPlugin: Successfully sourced html-webpack-plugin - %o', htmlWebpackPlugin);
167
+ return htmlWebpackPlugin;
168
+ }
169
+ exports.sourceHtmlWebpackPlugin = sourceHtmlWebpackPlugin;
170
+ // Most frameworks follow a similar path for sourcing webpack dependencies so this is a utility to handle all the sourcing.
171
+ function sourceDefaultWebpackDependencies(config) {
172
+ const framework = sourceFramework(config);
173
+ const webpack = sourceWebpack(config, framework);
174
+ const webpackDevServer = sourceWebpackDevServer(config, framework);
175
+ const htmlWebpackPlugin = sourceHtmlWebpackPlugin(config, framework, webpack);
176
+ return {
177
+ framework,
178
+ webpack,
179
+ webpackDevServer,
180
+ htmlWebpackPlugin,
181
+ };
182
+ }
183
+ exports.sourceDefaultWebpackDependencies = sourceDefaultWebpackDependencies;
184
+ function getMajorVersion(json, acceptedVersions) {
185
+ const major = Number(json.version.split('.')[0]);
186
+ if (!acceptedVersions.includes(major)) {
187
+ throw new Error(`Unexpected major version of ${json.name}. ` +
188
+ `Cypress webpack-dev-server works with ${json.name} versions ${acceptedVersions.join(', ')} - saw ${json.version}`);
189
+ }
190
+ return Number(major);
191
+ }
192
+ exports.getMajorVersion = getMajorVersion;
193
+ function restoreLoadHook() {
194
+ module_1.default._load = originalModuleLoad;
195
+ module_1.default._resolveFilename = originalModuleResolveFilename;
196
+ }
197
+ exports.restoreLoadHook = restoreLoadHook;
@@ -0,0 +1,2 @@
1
+ import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer';
2
+ export declare function vueCliHandler(devServerConfig: WebpackDevServerConfig): PresetHandlerResult;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vueCliHandler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
6
+ const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
7
+ const debug = (0, debug_1.default)('cypress:webpack-dev-server:vueCliHandler');
8
+ function vueCliHandler(devServerConfig) {
9
+ const sourceWebpackModulesResult = (0, sourceRelativeWebpackModules_1.sourceDefaultWebpackDependencies)(devServerConfig);
10
+ try {
11
+ const config = require.resolve('@vue/cli-service/webpack.config', {
12
+ paths: [devServerConfig.cypressConfig.projectRoot],
13
+ });
14
+ const webpackConfig = require(config);
15
+ debug('webpack config %o', webpackConfig);
16
+ return { frameworkConfig: webpackConfig, sourceWebpackModulesResult };
17
+ }
18
+ catch (e) {
19
+ console.error(e); // eslint-disable-line no-console
20
+ throw Error(`Error loading @vue/cli-service/webpack.config.js. Looked in ${require.resolve.paths(devServerConfig.cypressConfig.projectRoot)}`);
21
+ }
22
+ }
23
+ exports.vueCliHandler = vueCliHandler;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,3 @@
1
- /// <reference types="cypress" />
2
- import { StartDevServer, WebpackConfigurationWithDevServer } from './startServer';
3
- declare type DoneCallback = () => unknown;
4
- export interface ResolvedDevServerConfig {
5
- port: number;
6
- close: (done?: DoneCallback) => void;
7
- }
8
- export { StartDevServer };
9
- export declare function startDevServer(startDevServerArgs: StartDevServer, exitProcess?: (code?: number | undefined) => never): Promise<ResolvedDevServerConfig>;
10
- export interface CypressWebpackDevServerConfig {
11
- webpackConfig?: WebpackConfigurationWithDevServer;
12
- template?: string;
13
- }
14
- export declare function devServer(cypressDevServerConfig: Cypress.DevServerConfig, devServerConfig?: CypressWebpackDevServerConfig): Promise<ResolvedDevServerConfig>;
15
- export declare function defineDevServerConfig(devServerConfig: CypressWebpackDevServerConfig): CypressWebpackDevServerConfig;
1
+ import { devServer } from './devServer';
2
+ export { devServer };
3
+ export default devServer;
package/dist/index.js CHANGED
@@ -1,65 +1,6 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.defineDevServerConfig = exports.devServer = exports.startDevServer = void 0;
13
- const debug_1 = require("debug");
14
- const startServer_1 = require("./startServer");
15
- const webpackDevServerFacts_1 = require("./webpackDevServerFacts");
16
- const debug = (0, debug_1.debug)('cypress:webpack-dev-server:webpack');
17
- function startDevServer(startDevServerArgs, exitProcess = process.exit) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const webpackDevServer = yield (0, startServer_1.start)(startDevServerArgs, exitProcess);
20
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
21
- if (webpackDevServerFacts_1.webpackDevServerFacts.isV3()) {
22
- // @ts-ignore
23
- const server = webpackDevServer.listen(0, '127.0.0.1', () => {
24
- // FIXME: handle address returning a string
25
- const port = server.address().port;
26
- debug('Component testing webpack server started on port', port);
27
- resolve({
28
- port,
29
- close: (done) => {
30
- server.close();
31
- done === null || done === void 0 ? void 0 : done();
32
- },
33
- });
34
- });
35
- return;
36
- }
37
- if (webpackDevServerFacts_1.webpackDevServerFacts.isV4()) {
38
- yield webpackDevServer.start();
39
- resolve({
40
- // @ts-expect-error @types do not yet support v4
41
- port: webpackDevServer.options.port,
42
- close: (done) => {
43
- webpackDevServer.stop();
44
- done === null || done === void 0 ? void 0 : done();
45
- },
46
- });
47
- return;
48
- }
49
- reject(webpackDevServerFacts_1.webpackDevServerFacts.unsupported());
50
- }));
51
- });
52
- }
53
- exports.startDevServer = startDevServer;
54
- function devServer(cypressDevServerConfig, devServerConfig) {
55
- return startDevServer({
56
- options: cypressDevServerConfig,
57
- webpackConfig: devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.webpackConfig,
58
- template: devServerConfig === null || devServerConfig === void 0 ? void 0 : devServerConfig.template,
59
- });
60
- }
61
- exports.devServer = devServer;
62
- function defineDevServerConfig(devServerConfig) {
63
- return devServerConfig;
64
- }
65
- exports.defineDevServerConfig = defineDevServerConfig;
3
+ exports.devServer = void 0;
4
+ const devServer_1 = require("./devServer");
5
+ Object.defineProperty(exports, "devServer", { enumerable: true, get: function () { return devServer_1.devServer; } });
6
+ exports.default = devServer_1.devServer;
package/dist/loader.d.ts CHANGED
@@ -1,3 +1 @@
1
- import { CypressCTWebpackContext } from './plugin';
2
- import type { LoaderContext } from 'webpack';
3
- export default function loader(this: CypressCTWebpackContext & LoaderContext<void>): string;
1
+ export default function loader(this: unknown): string;
package/dist/loader.js CHANGED
@@ -1,31 +1,10 @@
1
1
  "use strict";
2
2
  /* global Cypress */
3
3
  /// <reference types="cypress" />
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
7
- }) : (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- o[k2] = m[k];
10
- }));
11
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
12
- Object.defineProperty(o, "default", { enumerable: true, value: v });
13
- }) : function(o, v) {
14
- o["default"] = v;
15
- });
16
- var __importStar = (this && this.__importStar) || function (mod) {
17
- if (mod && mod.__esModule) return mod;
18
- var result = {};
19
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
20
- __setModuleDefault(result, mod);
21
- return result;
22
- };
23
- var __importDefault = (this && this.__importDefault) || function (mod) {
24
- return (mod && mod.__esModule) ? mod : { "default": mod };
25
- };
26
4
  Object.defineProperty(exports, "__esModule", { value: true });
27
- const debug_1 = __importDefault(require("debug"));
28
- const path = __importStar(require("path"));
5
+ const tslib_1 = require("tslib");
6
+ const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
7
+ const path = (0, tslib_1.__importStar)(require("path"));
29
8
  const debug = (0, debug_1.default)('cypress:webpack-dev-server:webpack');
30
9
  /**
31
10
  * @param {ComponentSpec} file spec to create import string from.
@@ -37,13 +16,13 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
37
16
  // If we want to rename the chunks, we can use this
38
17
  const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : '';
39
18
  return `"${filename}": {
40
- shouldLoad: () => decodeURI(document.location.pathname).includes("${file.absolute}"),
19
+ shouldLoad: () => document.location.pathname.includes("${encodeURI(file.absolute)}"),
41
20
  load: () => import("${file.absolute}" ${magicComments}),
42
21
  chunkName: "${chunkName}",
43
22
  }`;
44
23
  };
45
24
  /**
46
- * Creates a object maping a spec file to an object mapping
25
+ * Creates a object mapping a spec file to an object mapping
47
26
  * the spec name to the result of `makeImport`.
48
27
  *
49
28
  * @returns {Record<string, ReturnType<makeImport>}
@@ -67,11 +46,12 @@ function buildSpecs(projectRoot, files = []) {
67
46
  }
68
47
  // Runs the tests inside the iframe
69
48
  function loader() {
49
+ const ctx = this;
70
50
  // In Webpack 5, a spec added after the dev-server is created won't
71
51
  // be included in the compilation. Disabling the caching of this loader ensures
72
52
  // we regenerate our specs and include any new ones in the compilation.
73
- this.cacheable(false);
74
- const { files, projectRoot, supportFile } = this._cypress;
53
+ ctx.cacheable(false);
54
+ const { files, projectRoot, supportFile } = ctx._cypress;
75
55
  const supportFileAbsolutePath = supportFile ? JSON.stringify(path.resolve(projectRoot, supportFile)) : undefined;
76
56
  return `
77
57
  var loadSupportFile = ${supportFile ? `() => import(${supportFileAbsolutePath})` : `() => Promise.resolve()`}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeDefaultWebpackConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
+ const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
7
+ const debug = (0, debug_1.default)('cypress:webpack-dev-server:makeDefaultWebpackConfig');
8
+ const OUTPUT_PATH = path_1.default.join(__dirname, 'dist');
9
+ /**
10
+ * @returns {import('webpack').Configuration}
11
+ * @internal
12
+ */
13
+ function makeDefaultWebpackConfig(config) {
14
+ const { module: _HtmlWebpackPlugin, packageJson: { version }, importPath, } = config.sourceWebpackModulesResult.htmlWebpackPlugin;
15
+ const indexHtmlFile = config.devServerConfig.cypressConfig.indexHtmlFile;
16
+ const HtmlWebpackPlugin = _HtmlWebpackPlugin;
17
+ debug(`Using HtmlWebpackPlugin version ${version} from ${importPath}`);
18
+ const finalConfig = {
19
+ mode: 'development',
20
+ optimization: {
21
+ splitChunks: {
22
+ chunks: 'all',
23
+ },
24
+ },
25
+ output: {
26
+ filename: '[name].js',
27
+ path: OUTPUT_PATH,
28
+ },
29
+ plugins: [
30
+ new HtmlWebpackPlugin({
31
+ // Todo: Add indexHtmlFile when it gets added as a config property
32
+ template: indexHtmlFile,
33
+ }),
34
+ ],
35
+ };
36
+ if (config.sourceWebpackModulesResult.webpackDevServer.majorVersion === 4) {
37
+ return Object.assign(Object.assign({}, finalConfig), { devServer: {
38
+ client: {
39
+ overlay: false,
40
+ },
41
+ } });
42
+ }
43
+ // @ts-ignore
44
+ return Object.assign(Object.assign({}, finalConfig), { devServer: {
45
+ overlay: false,
46
+ } });
47
+ }
48
+ exports.makeDefaultWebpackConfig = makeDefaultWebpackConfig;
@@ -1,16 +1,6 @@
1
- import * as webpack from 'webpack';
2
- import { CypressCTOptionsPluginOptionsWithEmitter } from './plugin';
3
- export interface UserWebpackDevServerOptions {
4
- /**
5
- * if `true` will compile all the specs together when the first one is request and can slow up initial build time.
6
- * @default false
7
- */
8
- disableLazyCompilation?: boolean;
9
- }
10
- interface MakeWebpackConfigOptions extends CypressCTOptionsPluginOptionsWithEmitter, UserWebpackDevServerOptions {
11
- devServerPublicPathRoute: string;
12
- isOpenMode: boolean;
13
- template?: string;
14
- }
15
- export declare function makeWebpackConfig(userWebpackConfig: webpack.Configuration, options: MakeWebpackConfigOptions): Promise<webpack.Configuration>;
16
- export {};
1
+ import type { CreateFinalWebpackConfig } from './createWebpackDevServer';
2
+ /**
3
+ * Creates a webpack 4/5 compatible webpack "configuration"
4
+ * to pass to the sourced webpack function
5
+ */
6
+ export declare function makeWebpackConfig(config: CreateFinalWebpackConfig): Promise<any>;