mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-10 19:39:10 -05:00
Merge pull request #16141 from cypress-io/b45fd0e8a-master-into-develop
This commit is contained in:
@@ -1343,6 +1343,7 @@ jobs:
|
||||
- run:
|
||||
name: Build
|
||||
command: yarn workspace @cypress/mount-utils build
|
||||
- store-npm-logs
|
||||
|
||||
npm-create-cypress-tests:
|
||||
<<: *defaults
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve, sep } from 'path'
|
||||
import { readFile } from 'fs'
|
||||
import { promisify } from 'util'
|
||||
import { Plugin, ViteDevServer } from 'vite'
|
||||
@@ -7,7 +7,9 @@ const read = promisify(readFile)
|
||||
|
||||
const pluginName = 'cypress-transform-html'
|
||||
|
||||
const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js')
|
||||
const OSSepRE = new RegExp(`\\${sep}`, 'g')
|
||||
|
||||
const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js').replace(OSSepRE, '/')
|
||||
|
||||
export const makeCypressPlugin = (
|
||||
projectRoot: string,
|
||||
@@ -16,6 +18,10 @@ export const makeCypressPlugin = (
|
||||
): Plugin => {
|
||||
let base = '/'
|
||||
|
||||
const posixSupportFilePath = supportFilePath ? resolve(projectRoot, supportFilePath).replace(OSSepRE, '/') : undefined
|
||||
|
||||
const normalizedSupportFilePath = posixSupportFilePath ? `${base}@fs/${posixSupportFilePath}` : undefined
|
||||
|
||||
return {
|
||||
name: pluginName,
|
||||
enforce: 'pre',
|
||||
@@ -23,7 +29,7 @@ export const makeCypressPlugin = (
|
||||
if (env) {
|
||||
return {
|
||||
define: {
|
||||
'import.meta.env.__cypress_supportPath': JSON.stringify(supportFilePath ? resolve(projectRoot, supportFilePath) : undefined),
|
||||
'import.meta.env.__cypress_supportPath': JSON.stringify(normalizedSupportFilePath),
|
||||
'import.meta.env.__cypress_originAutUrl': JSON.stringify('__cypress/iframes/'),
|
||||
},
|
||||
}
|
||||
@@ -40,7 +46,7 @@ export const makeCypressPlugin = (
|
||||
tag: 'script',
|
||||
injectTo: 'body',
|
||||
attrs: { type: 'module' },
|
||||
children: `import(${JSON.stringify(INIT_FILEPATH)})`,
|
||||
children: `import(${JSON.stringify(`${base}@fs/${INIT_FILEPATH}`)})`,
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user