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