mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-26 08:59:26 -05:00
03af592ca2
* chore: update @packages/reporter react from 16.8.6 to 17.0.2 and updates @types/react* packages from 16x to 17x [run ci] * hoist dependencies up due to peer dep issues with react and the runner/reporter needing to locate the same react (this is dumb) * update react-18 package to reference types delcared in root (kind of goofy but existing pattern) [run ci] * correctly look up react instance as __reactInternalInstance no longer exists in react17 [run ci] * fix failing test now that repo is on react 17 [run ci]
105 lines
2.5 KiB
TypeScript
105 lines
2.5 KiB
TypeScript
import _ from 'lodash'
|
|
import { waitUntilIconsBuilt } from '../../scripts/ensure-icons'
|
|
import { getCommonConfig, getSimpleConfig, getCopyWebpackPlugin } from '@packages/web-config/webpack.config.base'
|
|
import path from 'path'
|
|
import type webpack from 'webpack'
|
|
|
|
const commonConfig = getCommonConfig()
|
|
const CopyWebpackPlugin = getCopyWebpackPlugin()
|
|
|
|
// @ts-ignore
|
|
const babelLoader = _.find(commonConfig.module.rules, (rule) => {
|
|
// @ts-ignore
|
|
return _.includes(rule.use.loader, 'babel-loader')
|
|
})
|
|
|
|
// @ts-ignore
|
|
babelLoader.use.options.plugins.push([require.resolve('babel-plugin-prismjs'), {
|
|
'languages': ['javascript', 'coffeescript', 'typescript', 'jsx', 'tsx'],
|
|
'plugins': ['line-numbers', 'line-highlight'],
|
|
'theme': 'default',
|
|
'css': false,
|
|
}])
|
|
|
|
// @ts-ignore
|
|
const mainConfig: webpack.Configuration = {
|
|
...commonConfig,
|
|
entry: {
|
|
cypress_runner: [path.resolve(__dirname, 'src/index.js')],
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
}
|
|
|
|
mainConfig.resolve = {
|
|
...mainConfig.resolve,
|
|
alias: {
|
|
'bluebird': require.resolve('bluebird'),
|
|
'lodash': require.resolve('lodash'),
|
|
},
|
|
}
|
|
|
|
// @ts-ignore
|
|
const crossOriginConfig: webpack.Configuration = {
|
|
...commonConfig,
|
|
entry: {
|
|
cypress_cross_origin_runner: [path.resolve(__dirname, 'src/cross-origin.js')],
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
}
|
|
|
|
// @ts-ignore
|
|
const mainInjectionConfig: webpack.Configuration = {
|
|
...getSimpleConfig(),
|
|
mode: 'production',
|
|
entry: {
|
|
injection: [path.resolve(__dirname, 'injection/main.js')],
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
}
|
|
|
|
// @ts-ignore
|
|
const crossOriginInjectionConfig: webpack.Configuration = {
|
|
...getSimpleConfig(),
|
|
mode: 'production',
|
|
entry: {
|
|
injection_cross_origin: [path.resolve(__dirname, 'injection/cross-origin.js')],
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
}
|
|
|
|
export default async function () {
|
|
await waitUntilIconsBuilt()
|
|
|
|
const cyIcons = require('@packages/icons')
|
|
|
|
mainConfig.plugins = [
|
|
// @ts-ignore
|
|
...mainConfig.plugins,
|
|
new CopyWebpackPlugin({
|
|
patterns: [{
|
|
// @ts-ignore // There's a race condition in how these types are generated.
|
|
from: cyIcons.getPathToFavicon('favicon.ico'),
|
|
}],
|
|
}),
|
|
]
|
|
|
|
return [
|
|
mainConfig,
|
|
mainInjectionConfig,
|
|
crossOriginConfig,
|
|
crossOriginInjectionConfig,
|
|
]
|
|
}
|