Skip to content

Commit

Permalink
fix: apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart committed Apr 2, 2021
1 parent cc4db15 commit 3607477
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
10 changes: 2 additions & 8 deletions npm/webpack-dev-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { debug as debugFn } from 'debug'
import { AddressInfo } from 'net'
import { start as createDevServer } from './startServer'
import { UserWebpackDevServerOptions } from './makeWebpackConfig'
import { start as createDevServer, StartDevServer } from './startServer'

const debug = debugFn('cypress:webpack-dev-server:webpack')

Expand All @@ -12,12 +11,7 @@ export interface ResolvedDevServerConfig {
close: (done?: DoneCallback) => void
}

export interface StartDevServer extends UserWebpackDevServerOptions {
/* this is the Cypress options object */
options: Cypress.DevServerOptions
/* support passing a path to the user's webpack config */
webpackConfig?: Record<string, any>
}
export { StartDevServer }

export async function startDevServer (startDevServerArgs: StartDevServer, exitProcess = process.exit) {
const webpackDevServer = await createDevServer(startDevServerArgs, exitProcess)
Expand Down
23 changes: 8 additions & 15 deletions npm/webpack-dev-server/src/startServer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Debug from 'debug'
import webpack from 'webpack'
import WebpackDevServer from 'webpack-dev-server'
import { StartDevServer } from '@cypress/webpack-dev-server/src'
import { makeWebpackConfig } from './makeWebpackConfig'
import { makeWebpackConfig, UserWebpackDevServerOptions } from './makeWebpackConfig'

export interface StartDevServer extends UserWebpackDevServerOptions {
/* this is the Cypress options object */
options: Cypress.DevServerOptions
/* support passing a path to the user's webpack config */
webpackConfig?: Record<string, any>
}

const debug = Debug('cypress:webpack-dev-server:start')

Expand Down Expand Up @@ -40,19 +46,6 @@ export async function start ({ webpackConfig: userWebpackConfig, options, ...use

debug('starting webpack dev server')

// TODO: write a test for how we are NOT modifying publicPath
// here, and instead stripping it out of the cypress proxy layer
//
// ...this prevents a problem if users have a 'before' or 'after'
// function defined in their webpack config, it does NOT
// interfere with their routes... otherwise the public
// path we are prefixing like /__cypress/src/ would be
// prepended to req.url and cause their routing handlers to fail
//
// NOTE: we are merging in webpackConfig.devServer here so
// that user values for the devServer get passed on correctly
// since we are passing in the compiler directly, and these
// devServer options would otherwise get ignored
const webpackDevServerConfig = {
...userWebpackConfig.devServer,
hot: false,
Expand Down
1 change: 0 additions & 1 deletion npm/webpack-dev-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"target": "es2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"skipLibCheck": true,
"resolveJsonModule": true,
"lib": [
"es2015",
"dom"
Expand Down

0 comments on commit 3607477

Please sign in to comment.