-
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not execute on a child compiler
- Loading branch information
1 parent
6d51a69
commit 42f27c7
Showing
7 changed files
with
362 additions
and
303 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export default class ChildCompiler { | ||
// eslint-disable-next-line class-methods-use-this | ||
apply(compiler) { | ||
compiler.hooks.make.tapAsync('Child Compiler', (compilation, callback) => { | ||
const outputOptions = { | ||
filename: 'output.js', | ||
publicPath: compilation.outputOptions.publicPath, | ||
}; | ||
const childCompiler = compilation.createChildCompiler( | ||
'ChildCompiler', | ||
outputOptions | ||
); | ||
childCompiler.runAsChild((error, entries, childCompilation) => { | ||
if (error) { | ||
throw error; | ||
} | ||
|
||
const assets = childCompilation.getAssets(); | ||
|
||
if (assets.length > 0) { | ||
callback( | ||
new Error('Copy plugin should not be ran in child compilations') | ||
); | ||
|
||
return; | ||
} | ||
|
||
callback(); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters