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

cli(add): support for webpack config file #501

Merged
merged 4 commits into from
Jun 12, 2018

Conversation

dhruvdutt
Copy link
Member

What kind of change does this PR introduce?
Feature

Did you add tests for your changes?
No

If relevant, did you update the documentation?
Yes

Summary
Add support to specify webpack config file with args, default to webpack.config.js

  • Specifying config file: webpack-cli add webpack.dev.js

image

  • Default config file: webpack-cli add

image

  • Non-existential file: webpack-cli add aaahha.js

image

Similar usage for update, remove.

Does this PR introduce a breaking change?
No

Fixes #279

module.exports = function add(...args) {
const DEFAULT_WEBPACK_CONFIG_FILENAME = "webpack.config.js";

const filePaths = args.slice(3);
Copy link
Member

Choose a reason for hiding this comment

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

Why are you slicing 3 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because first 3 args would be node path, webpack-cli path, add command.
4th item in the array would be everything after add command like the custom config path/name. So, we're slicing first three items to get the config path.

We can't directly use the last element of args because that would be "add" if the user doesn't mention any arg after add.

Copy link
Member

Choose a reason for hiding this comment

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

Oki. let me check it out later to make sure its working 👍

@@ -3,7 +3,7 @@
const path = require("path");
const chalk = require("chalk");

const modifyConfigHelper = require("./modify-config-helper");
const modifyConfig = require("./modify-config-helper");
Copy link
Member

Choose a reason for hiding this comment

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

don't see a reason to change this

Copy link
Member Author

Choose a reason for hiding this comment

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

For consistency.
We're using modifyConfig everywhere across at codebase other than this place.

Please check this: https://github.com/webpack/webpack-cli/search?q=return+modifyHelper&unscoped_q=return+modifyHelper

Copy link
Member

Choose a reason for hiding this comment

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

Use the previous convention 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated all occurrences to use the previous convention.

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

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

Generator is defined twice in the modifyconfig helper & the generator is not runnable. Good work though!

@evenstensberg evenstensberg merged commit 295d1e2 into webpack:master Jun 12, 2018
@evenstensberg
Copy link
Member

🎉 This PR is included in version 3.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dhruvdutt dhruvdutt deleted the add-config branch August 13, 2018 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants