Skip to content

Commit 42d6684

Browse files
authored
docs: improve getting started guide formatting and CLI output readability (#8078)
1 parent 3b263f9 commit 42d6684

1 file changed

Lines changed: 42 additions & 3 deletions

File tree

src/content/guides/getting-started.mdx

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,18 @@ First let's create a directory, initialize npm, [install webpack locally](/guide
5656
```bash
5757
mkdir webpack-demo
5858
cd webpack-demo
59+
60+
# npm
5961
npm init -y
6062
npm install webpack webpack-cli --save-dev
63+
64+
# yarn
65+
yarn init -y
66+
yarn add webpack webpack-cli --dev
67+
68+
# pnpm
69+
pnpm init
70+
pnpm add webpack webpack-cli -D
6171
```
6272

6373
Throughout the Guides we will use **`diff`** blocks to show you what changes we're making to directories, files, and code. For instance:
@@ -171,7 +181,14 @@ T> You may have noticed that `index.html` was created manually, even though it i
171181
To bundle the `lodash` dependency with `index.js`, we'll need to install the library locally:
172182

173183
```bash
184+
# npm
174185
npm install --save lodash
186+
187+
# yarn
188+
yarn add lodash
189+
190+
# pnpm
191+
pnpm add lodash
175192
```
176193

177194
T> When installing a package that will be bundled into your production bundle, you should use `npm install --save`. If you're installing a package for development purposes (e.g. a linter, testing libraries, etc.) then you should use `npm install --save-dev`. More information can be found in the [npm documentation](https://docs.npmjs.com/cli/install).
@@ -222,7 +239,15 @@ In this setup, `index.js` explicitly requires `lodash` to be present, and binds
222239
With that said, let's run `npx webpack` from the project root. If webpack is installed locally, `npx` will run the local binary from `node_modules/.bin`; otherwise, it may download and execute it. This command takes our script at `src/index.js` as the [entry point](/concepts/entry-points) and generates `dist/main.js` as the [output](/concepts/output).
223240

224241
```bash
225-
$ npx webpack
242+
# npm
243+
npx webpack
244+
245+
# yarn
246+
yarn webpack
247+
248+
# pnpm
249+
pnpm exec webpack
250+
226251
[webpack-cli] Compilation finished
227252
asset main.js 69.3 KiB [emitted] [minimized] (name: main) 1 related asset
228253
runtime modules 1000 bytes 5 modules
@@ -287,7 +312,15 @@ export default {
287312
Now, let's run the build again but instead using our new configuration file:
288313
289314
```bash
290-
$ npx webpack --config webpack.config.js
315+
# npm
316+
npx webpack --config webpack.config.js
317+
318+
# yarn
319+
yarn webpack --config webpack.config.js
320+
321+
# pnpm
322+
pnpm exec webpack --config webpack.config.js
323+
291324
[webpack-cli] Compilation finished
292325
asset main.js 69.3 KiB [compared for emit] [minimized] (name: main) 1 related asset
293326
runtime modules 1000 bytes 5 modules
@@ -336,8 +369,14 @@ Now the `npm run build` command can be used in place of the `npx` command we use
336369
Now run the following command and see if your script alias works:
337370
338371
```bash
339-
$ npm run build
372+
# npm
373+
npm run build
374+
375+
# yarn
376+
yarn build
340377

378+
# pnpm
379+
pnpm run build
341380
...
342381

343382
[webpack-cli] Compilation finished

0 commit comments

Comments
 (0)