Skip to content

Commit

Permalink
fix: windows path resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 25, 2021
1 parent a515786 commit a8293b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/webpack/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import { fileURLToPath } from 'url'
import { resolve, dirname, join } from 'path'
import { resolve, dirname } from 'path'
import VirtualModulesPlugin from 'webpack-virtual-modules'
import type { Resolver, ResolveRequest } from 'enhanced-resolve'
import type { UnpluginContextMeta, UnpluginInstance, UnpluginFactory, WebpackCompiler, ResolvedUnpluginOptions } from '../types'
Expand All @@ -26,12 +26,17 @@ export function getWebpackPlugin<UserOptions = {}> (
}
}

let virtualModulePrefix = slash(resolve(process.cwd(), '_virtual_'))
if (!virtualModulePrefix.startsWith('/')) {
virtualModulePrefix = '/' + virtualModulePrefix
}

const rawPlugin = factory(userOptions, meta)
const plugin = Object.assign(
rawPlugin,
{
__unpluginMeta: meta,
__virtualModulePrefix: slash(join(process.cwd(), '_virtual_'))
__virtualModulePrefix: virtualModulePrefix
}
) as ResolvedUnpluginOptions

Expand Down

0 comments on commit a8293b8

Please sign in to comment.