Skip to content

Commit 560e0c7

Browse files
committed
chore: add webpack 4 migration guide / workarounds
1 parent 4fa879e commit 560e0c7

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

docs/app/references/migration-guide.mdx

+63
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,69 @@ Cypress requires [Node.js](https://nodejs.org/en) in order to install the Cypres
2020
Node.js versions 18 and 23 are no longer supported.
2121
[See Node's release schedule](https://github.com/nodejs/Release).
2222

23+
### Webpack `4` is no longer supported
24+
25+
Cypress is no longer supporting Webpack `4` as it is no longer maintained by the core Webpack team and Webpack `5` has been available since Q4 2020. This includes Webpack `4` support for:
26+
27+
- `@cypress/webpack-batteries-included-preprocessor` and `@cypress/webpack-preprocessor` for end-to-end testing. This is mostly a passive change unless you are using a specific webpack configuration to preprocess your tests, which is uncommon.
28+
- `@cypress/webpack-dev-server` for component testing. This use case is more common and will require an to update to Webpack `5`.
29+
30+
#### To continue using Webpack `4`
31+
32+
##### End-to-End Testing
33+
34+
If you haven't been able to migrate away from Webpack `4` and still need to be able to run your end-to-end tests with Webpack `4`, you can install the following packages independently:
35+
36+
```sh
37+
npm install --save-dev @cypress/[email protected] @cypress/[email protected]
38+
```
39+
40+
and configure the preprocessor within your `cypress.config.js` or `cypress.config.ts` file:
41+
42+
```js
43+
import { defineConfig } from 'cypress'
44+
import webpackPreprocessor from '@cypress/webpack-batteries-included-preprocessor'
45+
46+
export default defineConfig({
47+
e2e: {
48+
setupNodeEvents(on, config) {
49+
on('file:preprocessor', webpackPreprocessor())
50+
},
51+
},
52+
})
53+
```
54+
55+
More information on how to configure the preprocessor can be found in the [Preprocessors API documentation](https://docs.cypress.io/api/node-events/preprocessors-api#Usage), the [Webpack Batteries Included Preprocessor documentation](https://github.com/cypress-io/cypress/blob/v14.3.2/npm/webpack-batteries-included-preprocessor/README.md), and [Webpack Preprocessor documentation](https://github.com/cypress-io/cypress/blob/v14.3.2/npm/webpack-preprocessor/README.md).
56+
57+
##### Component Testing
58+
59+
If you haven't been able to migrate away from Webpack `4` and still need to be able to run your component tests with Webpack `4`, you can install the following packages independently:
60+
61+
```sh
62+
npm install --save-dev @cypress/[email protected]
63+
```
64+
65+
and configure the dev server within your `cypress.config.js` or `cypress.config.ts` file:
66+
67+
```js
68+
import { devServer } from '@cypress/webpack-dev-server'
69+
import { defineConfig } from 'cypress'
70+
71+
export default defineConfig({
72+
component: {
73+
devServer(devServerConfig) {
74+
return devServer({
75+
...devServerConfig,
76+
framework: 'react',
77+
webpackConfig: require('./webpack.config.js'),
78+
})
79+
},
80+
},
81+
})
82+
```
83+
84+
More information on how to configure the dev server can be found in the [Cypress Webpack Dev Server documentation](https://github.com/cypress-io/cypress/blob/v14.3.2/npm/webpack-dev-server/README.md) and [Custom Dev Server documentation](https://docs.cypress.io/app/component-testing/component-framework-configuration#Custom-Dev-Server/).
85+
2386
### Angular `17` CT no longer supported
2487

2588
With [LTS ending](https://angular.dev/reference/releases#actively-supported-versions) for Angular 17, the minimum required Angular version for component testing is now `18.0.0`.

0 commit comments

Comments
 (0)