Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(generator): using configFile in configPath to get the config file name #883

Merged
merged 10 commits into from May 24, 2019
8 changes: 2 additions & 6 deletions packages/generators/remove-generator.ts
Expand Up @@ -32,13 +32,9 @@ export default class RemoveGenerator extends Generator {
webpackOptions: {}
}
};

let configPath = path.resolve(process.cwd(), "webpack.config.js");
const { configFile } = opts;
let configPath = path.resolve(process.cwd(), configFile);
const webpackConfigExists = fs.existsSync(configPath);
if (!webpackConfigExists) {
configPath = null;
// end the generator stating webpack config not found or to specify the config
}
this.webpackOptions = require(configPath);
}

Expand Down
9 changes: 5 additions & 4 deletions packages/utils/modify-config-helper.ts
Expand Up @@ -64,7 +64,7 @@ export default function modifyHelperUtil(
logSymbols.error +
chalk.red(" ERROR ") +
chalk.cyan(configFile) +
" not found. Please specify a valid path to your webpack config like " +
" not found. Please specify a valid path to your webpack config like \n " +
chalk.white("$ ") +
chalk.cyan(`webpack-cli ${action} webpack.dev.js`) +
"\n"
Expand All @@ -87,10 +87,11 @@ export default function modifyHelperUtil(
}
};
}

env.registerStub(generator, generatorName);

env.run(generatorName)
.then(
env.run(generatorName, {
configFile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To pass the config file name to the generator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is probably ok and needed as we need this to be dynamic. Just gotta check that it works. Change is that the generator will have output of the config file supplied vs webpack.config.js

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I used this in my machine and its working fine. This can use workable with the other generators too like the update one and in add too

}).then(
(): void => {
let configModule: object;
try {
Expand Down