Skip to content

Commit

Permalink
fix: let vite handle resolving the config file
Browse files Browse the repository at this point in the history
Fixes `vite@3.1.3` breaks `cypress-vite` mammadataei#5
  • Loading branch information
DrJume committed Oct 18, 2022
1 parent 939a0a7 commit a9c9d65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
15 changes: 4 additions & 11 deletions src/index.ts
Expand Up @@ -2,7 +2,6 @@ import path from 'path'
import Debug from 'debug'
import { build, InlineConfig } from 'vite'
import type { RollupOutput, RollupWatcher, WatcherOptions } from 'rollup'
import { getConfig, resolveConfig } from './resolveConfig'

type FileObject = Cypress.FileObject
type CypressPreprocessor = (file: FileObject) => string | Promise<string>
Expand All @@ -25,12 +24,6 @@ const cache: Record<string, string> = {}
function vitePreprocessor(userConfigPath?: string): CypressPreprocessor {
debug('User config path: %s', userConfigPath)

if (userConfigPath) {
resolveConfig(userConfigPath).then((config) => {
debug('Resolved user config:', config)
})
}

return async (file) => {
const { outputPath, filePath, shouldWatch } = file
debug('Preprocessing file %s', filePath)
Expand Down Expand Up @@ -67,10 +60,10 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor {
},
}

const buildConfig = getConfig(defaultConfig)
debug('Build config for file %s:', filePath, buildConfig)

const watcher = await build(buildConfig)
const watcher = await build({
configFile: userConfigPath,
...defaultConfig,
})

if (shouldWatch && isWatcher(watcher)) {
watcher.on('event', (event) => {
Expand Down
26 changes: 0 additions & 26 deletions src/resolveConfig.ts

This file was deleted.

0 comments on commit a9c9d65

Please sign in to comment.