mirror of https://github.com/webpack/webpack.git
update
This commit is contained in:
parent
018160e44d
commit
daa38aa735
|
@ -122,6 +122,9 @@ class DotenvPlugin {
|
|||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
/** @type {string[] | undefined} */
|
||||
let fileDependenciesCache;
|
||||
|
||||
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (_params, callback) => {
|
||||
const inputFileSystem = /** @type {InputFileSystem} */ (
|
||||
compiler.inputFileSystem
|
||||
|
@ -133,21 +136,20 @@ class DotenvPlugin {
|
|||
context,
|
||||
(err, variables, fileDependencies) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
if (fileDependencies) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
||||
compilation.fileDependencies.addAll(fileDependencies);
|
||||
});
|
||||
}
|
||||
|
||||
const definitions = this.formatVariables(variables || {});
|
||||
const DefinePlugin = compiler.webpack.DefinePlugin;
|
||||
|
||||
new DefinePlugin(definitions).apply(compiler);
|
||||
fileDependenciesCache = fileDependencies;
|
||||
|
||||
callback();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
||||
compilation.fileDependencies.addAll(fileDependenciesCache || []);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue