Cypress从9.5.4升级到10.11.0后Webpack编译错误求助
Cypress 9.5.4 迁移至 10.11.0 后 Webpack 编译错误排查求助
我将Cypress从9.5.4版本迁移至10.11.0版本后,出现了大量此前未遇到的Webpack编译错误。部分错误已通过@cypress/webpack-preprocessor解决,但仍有部分无法处理,恳请协助解决截图中的问题。
相关配置代码如下:
const findWebpack = require('find-webpack'); const injectDevServer = require('@cypress/react/plugins/react-scripts'); const webpackPreprocessor = require('@cypress/webpack-preprocessor'); /** * @type {Cypress.PluginConfig} */ module.exports = (on, config) => { // const webpack = require('./webpack.config.js'); // find the Webpack config used by react-scripts const webpackOptions = findWebpack.getWebpackOptions(); if (!webpackOptions) { throw new Error('Could not find Webpack in this project 😢'); } // if we just pass webpackOptions to the preprocessor // it won't work - because react-scripts by default // includes plugins that split specs into chunks, etc. // https://github.com/cypress-io/cypress-webpack-preprocessor/issues/31 // solution 1 // blunt: delete entire optimization object // delete webpackOptions.optimization // solution 2 // use a module that carefully removes only plugins // that we found to be breaking the bundling // https://github.com/bahmutov/find-webpack const cleanOptions = { reactScripts: true, }; findWebpack.cleanForCypress(cleanOptions, webpackOptions); const options = { webpackOptions, watchOptions: {}, }; injectDevServer(on, config); on('file:preprocessor', webpackPreprocessor(options)); return config; };

内容的提问来源于stack exchange,提问作者anna swan
相关产品推荐
相关产品推荐

