@@ -2,7 +2,7 @@ import { debug as debugFn } from 'debug'
2
2
import * as path from 'path'
3
3
import { merge } from 'webpack-merge'
4
4
import { importModule } from 'local-pkg'
5
- import type { Configuration } from 'webpack'
5
+ import type { Configuration , EntryObject } from 'webpack'
6
6
import { makeDefaultWebpackConfig } from './makeDefaultWebpackConfig'
7
7
import { CypressCTWebpackPlugin } from './CypressCTWebpackPlugin'
8
8
import type { CreateFinalWebpackConfig } from './createWebpackDevServer'
@@ -41,7 +41,7 @@ if (process.platform === 'linux') {
41
41
const OsSeparatorRE = RegExp ( `\\${ path . sep } ` , 'g' )
42
42
const posixSeparator = '/'
43
43
44
- const CYPRESS_WEBPACK_ENTRYPOINT = path . resolve ( __dirname , 'browser.js' )
44
+ export const CYPRESS_WEBPACK_ENTRYPOINT = path . resolve ( __dirname , 'browser.js' )
45
45
46
46
/**
47
47
* Removes and/or modifies certain plugins known to conflict
@@ -72,29 +72,6 @@ function modifyWebpackConfigForCypress (webpackConfig: Partial<Configuration>) {
72
72
return webpackConfig
73
73
}
74
74
75
- async function addEntryPoint ( webpackConfig : Configuration ) {
76
- let entry = webpackConfig . entry
77
-
78
- if ( typeof entry === 'function' ) {
79
- entry = await entry ( )
80
- }
81
-
82
- if ( typeof entry === 'string' ) {
83
- entry = [ entry , CYPRESS_WEBPACK_ENTRYPOINT ]
84
- } else if ( Array . isArray ( entry ) ) {
85
- entry . push ( CYPRESS_WEBPACK_ENTRYPOINT )
86
- } else if ( typeof entry === 'object' ) {
87
- entry = {
88
- ...entry ,
89
- [ 'cypress-entry' ] : CYPRESS_WEBPACK_ENTRYPOINT ,
90
- }
91
- } else {
92
- entry = CYPRESS_WEBPACK_ENTRYPOINT
93
- }
94
-
95
- webpackConfig . entry = entry
96
- }
97
-
98
75
/**
99
76
* Creates a webpack 4/5 compatible webpack "configuration"
100
77
* to pass to the sourced webpack function
@@ -113,6 +90,7 @@ export async function makeWebpackConfig (
113
90
} ,
114
91
specs : files ,
115
92
devServerEvents,
93
+ framework,
116
94
} = config . devServerConfig
117
95
118
96
let configFile : string | undefined = undefined
@@ -184,7 +162,15 @@ export async function makeWebpackConfig (
184
162
dynamicWebpackConfig ,
185
163
)
186
164
187
- await addEntryPoint ( mergedConfig )
165
+ // Angular loads global styles and polyfills via script injection in the index.html
166
+ if ( framework === 'angular' ) {
167
+ mergedConfig . entry = {
168
+ ...( mergedConfig . entry as EntryObject ) || { } ,
169
+ 'cypress-entry' : CYPRESS_WEBPACK_ENTRYPOINT ,
170
+ }
171
+ } else {
172
+ mergedConfig . entry = CYPRESS_WEBPACK_ENTRYPOINT
173
+ }
188
174
189
175
debug ( 'Merged webpack config %o' , mergedConfig )
190
176
0 commit comments