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

docs: init documentaion #547

Merged
merged 5 commits into from
Jul 19, 2018
Merged
Changes from 3 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
52 changes: 48 additions & 4 deletions INIT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
## webpack init
# webpack-cli init

Through [yeoman](http://yeoman.io/), the `webpack-cli init` feature allows people to create scaffolds and generate new projects quickly. An npm dependency that scaffolds a `webpack.config.js` through `webpack-cli` is what we refer to as an **addon**.
`webpack-cli init` is used to initialize `webpack` projects quickly by scaffolding configuration and installing modules required for the project as per user preferences.

We ask several questions in the default generator to get you started.
## Initial Setup
A. **Local setup**

---
Follow given steps to locally setup `webpack-cli init` by installing dependencies:
1. Create `package.json` through npm

```shell
$ npm init
```

2. Install `webpack` and `webpack-cli` as devDependencies

```shell
$ npm install --save-dev webpack webpack-cli
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be consistent and would write --save-dev or -D, not both. They are basically the same. -D is just an alias

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 it @ematipico

```

3. Install @webpack-cli/init package to add init addon
Copy link
Member

Choose a reason for hiding this comment

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

@webpack-cli/init => @webpack-cli/init


```shell
$ npm install -D @webpack-cli/init
```

B. **Global Setup**

Follow following steps to setup `webpack-cli init` globally:
1. Install `webpack` and `webpack-cli` globally
```shell
$ sudo npm install -g webpack webpack-cli
Copy link
Member

Choose a reason for hiding this comment

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

Why doing sudo? Global modules are installed at user level, not root.

If you get errors in permission if you remove sudo then you probably have installed node/npm incorrectly in your local machine. Find the fix on Google. For now, remove sudo from 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.

Yes, I was getting errors,
Will remove sudo from both steps in next commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dhruvdutt , also I wasn't able to install webpack-cli globally using npm but webpack was installed.
Added this because it is only method (i.e. using -g flag) makes sense to me.

Copy link
Member

Choose a reason for hiding this comment

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

What error are you getting?

Copy link
Member Author

Choose a reason for hiding this comment

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

On running this:
$ sudo npm install -g webpack-cli

npm WARN checkPermissions Missing write access to /usr/lib/node_modules/webpack-cli
npm WARN webpack-cli@3.0.8 requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.

I have webpack@4.16.1
But was able to setup webpack-command

Copy link
Member

Choose a reason for hiding this comment

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

This issue is not related to webpack-cli. It happens because you've installed node/npm with incorrect permission. This is a common issue which I've also experienced it. You can Google it and find a fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I was able to fix it by setting it up using nvm .

```

2. Install @webpack-cli/init package to add init addon
Copy link
Member

Choose a reason for hiding this comment

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

@webpack-cli/init => @webpack-cli/init

```shell
$ sudo npm install -g @webpack-cli/init
```

## Usage
A. **For local setup**:
```shell
$ npx webpack-cli init
```

B. **For global setup**
```shell
$ webpack-cli init
```

### Questions asked by generator
Copy link
Member

Choose a reason for hiding this comment

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

Nice work. 💯 🥇

How about mentioning which specific property/key the question is related to and also provide a link to webpack docs for every question? Similar to how you did for entry. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I will where ever possible in next commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

this has been resolved @dhruvdutt ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks good. Why have we skipped mentioning property for the last question?


1. `Will your application have multiple bundles? (Y/n)`

Expand Down