Browse Source

chore: 去掉编译过程中NotFoundExport的警告

es6
iapyang 3 years ago
parent
commit
6082eb32b4
  1. 23
      webpack/webpack.dev.js

23
webpack/webpack.dev.js

@ -9,6 +9,28 @@ const dirs = require("./dirs");
const common = require("./webpack.common.js"); const common = require("./webpack.common.js");
const ModuleDependencyWarning = require("webpack/lib/ModuleDependencyWarning");
class IgnoreNotFoundExportPlugin {
apply(compiler) {
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/;
function doneHook(stats) {
stats.compilation.warnings = stats.compilation.warnings.filter(warn => {
if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) {
return false;
}
return true;
});
}
if (compiler.hooks) {
compiler.hooks.done.tap("IgnoreNotFoundExportPlugin", doneHook);
} else {
compiler.plugin("done", doneHook);
}
}
}
module.exports = merge(common, { module.exports = merge(common, {
devtool: "source-map", devtool: "source-map",
output: { output: {
@ -46,5 +68,6 @@ module.exports = merge(common, {
}, },
canPrint: true, canPrint: true,
}), }),
new IgnoreNotFoundExportPlugin(),
], ],
}); });

Loading…
Cancel
Save