Skip to content

Commit 6f2f455

Browse files
feat: use webpack input filesystem (#531)
1 parent f2ac763 commit 6f2f455

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ class CopyPlugin {
8787
`getting stats for "${pattern.absoluteFrom}" to determinate "fromType"`
8888
);
8989

90+
const { inputFileSystem } = compiler;
91+
9092
let stats;
9193

9294
try {
93-
stats = await stat(compiler.inputFileSystem, pattern.absoluteFrom);
95+
stats = await stat(inputFileSystem, pattern.absoluteFrom);
9496
} catch (error) {
9597
// Nothing
9698
}
@@ -110,6 +112,18 @@ class CopyPlugin {
110112
...{ cwd: pattern.context, objectMode: true },
111113
};
112114

115+
// TODO remove after drop webpack@4
116+
if (
117+
inputFileSystem.lstat &&
118+
inputFileSystem.stat &&
119+
inputFileSystem.lstatSync &&
120+
inputFileSystem.statSync &&
121+
inputFileSystem.readdir &&
122+
inputFileSystem.readdirSync
123+
) {
124+
pattern.globOptions.fs = inputFileSystem;
125+
}
126+
113127
switch (pattern.fromType) {
114128
case 'dir':
115129
logger.debug(`determined "${pattern.absoluteFrom}" is a directory`);
@@ -257,7 +271,7 @@ class CopyPlugin {
257271
let data;
258272

259273
try {
260-
data = await readFile(compiler.inputFileSystem, file.absoluteFrom);
274+
data = await readFile(inputFileSystem, file.absoluteFrom);
261275
} catch (error) {
262276
compilation.errors.push(error);
263277

0 commit comments

Comments
 (0)