Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/generators/add-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ export default class AddGenerator extends Generator {
* find the names of each natively plugin and check if it matches
*/
if (action === "plugins") {
let answeredPluginName = answerToAction.actionAnswer;
let isPrefixPresent = /webpack./.test(answeredPluginName);

if (isPrefixPresent) {
answeredPluginName = answeredPluginName.replace("webpack.", "").trim();
} else {
answeredPluginName = answeredPluginName.trim();
}
const pluginExist: string = glob
.sync(["node_modules/webpack/lib/*Plugin.js", "node_modules/webpack/lib/**/*Plugin.js"])
.map(
Expand All @@ -300,7 +308,7 @@ export default class AddGenerator extends Generator {
.pop()
.replace(".js", "")
)
.find((p: string): boolean => p.toLowerCase().indexOf(answerToAction.actionAnswer) >= 0);
.find((p: string): boolean => p.toLowerCase().indexOf(answeredPluginName) >= 0);

if (pluginExist) {
this.configuration.config.item = pluginExist;
Expand All @@ -315,8 +323,7 @@ export default class AddGenerator extends Generator {
.split("/")
.pop()
.replace(".json", "")
.toLowerCase()
.indexOf(answerToAction.actionAnswer) >= 0
.indexOf(answeredPluginName) >= 0
);
if (pluginsSchemaPath) {
const constructorPrefix: string =
Expand Down