Skip to content

Commit

Permalink
fix(webpack): allow load custom asset on windows (#16099)
Browse files Browse the repository at this point in the history
* fix(webpack): allow load custom asset on windows

closes #16097

* fix: use a regexp and path.sep

* chore: avoid replacement when using posix filesystem
  • Loading branch information
elevatebart committed Apr 21, 2021
1 parent 98028a5 commit 7340851
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions npm/webpack-dev-server/src/makeWebpackConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ interface MakeWebpackConfigOptions extends CypressCTOptionsPluginOptions, UserWe
isOpenMode: boolean
}

const OsSeparatorRE = RegExp(`\\${path.sep}`, 'g')
const posixSeparator = '/'

export async function makeWebpackConfig (userWebpackConfig: webpack.Configuration, options: MakeWebpackConfigOptions): Promise<webpack.Configuration> {
const { projectRoot, devServerPublicPathRoute, files, supportFile, devServerEvents } = options

Expand All @@ -32,8 +35,12 @@ export async function makeWebpackConfig (userWebpackConfig: webpack.Configuratio
debug(`Support file`, supportFile)

const entry = path.resolve(__dirname, './browser.js')

const publicPath = path.join(devServerPublicPathRoute, '/')
const publicPath = (path.sep === posixSeparator)
? path.join(devServerPublicPathRoute, posixSeparator)
// The second line here replaces backslashes on windows with posix compatible slash
// See https://github.com/cypress-io/cypress/issues/16097
: path.join(devServerPublicPathRoute, posixSeparator)
.replace(OsSeparatorRE, posixSeparator)

const dynamicWebpackConfig = {
output: {
Expand Down

0 comments on commit 7340851

Please sign in to comment.