Skip to content

Commit b8bcf1e

Browse files
Configure webpack-preprocessor in cypress.config
1 parent cab48d3 commit b8bcf1e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cypress.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
/* eslint-disable no-undef */
22
const { defineConfig } = require('cypress');
33
const fs = require('fs');
4+
const { resolve } = require('path');
5+
// TODO: Upgrade @cypress/webpack-preprocessor to latest once Webpack is upgraded
6+
const webpackPreprocessor = require('@cypress/webpack-preprocessor');
7+
// TODO: Use webpack-configs from shared.js once Webpack is upgraded
8+
// const webpackConfigOptions = require('./config/webpack/shared.js');
9+
10+
// TODO: Relocate the aliases to webpack-config and reference its options directly from shared.js.
11+
const webpackConfigOptions = {
12+
resolve: {
13+
alias: {
14+
'@cypress-dir': resolve(__dirname, 'cypress'),
15+
},
16+
extensions: ['.js'],
17+
},
18+
};
419

520
module.exports = defineConfig({
621
e2e: {
@@ -44,6 +59,12 @@ module.exports = defineConfig({
4459
console.log('Actual args:', launchOptions.args);
4560
return launchOptions;
4661
});
62+
on(
63+
'file:preprocessor',
64+
webpackPreprocessor({
65+
webpackOptions: webpackConfigOptions,
66+
})
67+
);
4768
},
4869
},
4970
});

0 commit comments

Comments
 (0)