Skip to content

Commit 1099b34

Browse files
authored
webpack-plugin: Fix extracted file resolution when deeply nested (#195)
1 parent b53f065 commit 1099b34

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.changeset/quiet-cycles-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vanilla-extract/webpack-plugin': patch
3+
---
4+
5+
Fix issue when @vanilla-extract/webpack-plugin is nested within a separate node_modules folder

packages/webpack-plugin/src/loader.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'path';
12
// @ts-expect-error
23
import loaderUtils from 'loader-utils';
34
import { processVanillaFile } from '@vanilla-extract/integration';
@@ -6,6 +7,15 @@ import type { LoaderContext } from './types';
67
import { debug, formatResourcePath } from './logger';
78
import { ChildCompiler } from './compiler';
89

10+
const emptyCssExtractionFile = require.resolve(
11+
path.join(
12+
path.dirname(
13+
require.resolve('@vanilla-extract/webpack-plugin/package.json'),
14+
),
15+
'extracted',
16+
),
17+
);
18+
919
interface LoaderOptions {
1020
outputCss: boolean;
1121
}
@@ -59,7 +69,7 @@ export function pitch(this: LoaderContext) {
5969

6070
const request = loaderUtils.stringifyRequest(
6171
this,
62-
`${fileName}!=!${virtualResourceLoader}!@vanilla-extract/webpack-plugin/extracted`,
72+
`${fileName}!=!${virtualResourceLoader}!${emptyCssExtractionFile}`,
6373
);
6474

6575
return `import ${request}`;

0 commit comments

Comments
 (0)