Skip to content

Commit 94db1bd

Browse files
author
kingdaro
committed
feat: add helpful error messages for removed plugins
1 parent c963e3d commit 94db1bd

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎lib/webpack.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,23 @@ exportPlugins(exports.node = {}, {
132132
exportPlugins(exports.debug = {}, {
133133
"ProfilingPlugin": () => require("./debug/ProfilingPlugin"),
134134
});
135+
136+
const defineMissingPluginError = (pluginName, errorMessage) => {
137+
Reflect.defineProperty(exports.optimize, pluginName, {
138+
configurable: false,
139+
enumerable: true,
140+
get() {
141+
throw new Error(errorMessage);
142+
}
143+
});
144+
}
145+
146+
defineMissingPluginError(
147+
"UglifyJsPlugin",
148+
"webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead."
149+
)
150+
151+
defineMissingPluginError(
152+
"CommonsChunkPlugin",
153+
"webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead."
154+
)

0 commit comments

Comments
 (0)