Skip to content

Commit ab04fb6

Browse files
committed
docs(api): rewrite the index page
1 parent af236c6 commit ab04fb6

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

src/content/api/cli.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ related:
1717
url: https://medium.com/@nimgrg/analysing-and-minimising-the-size-of-client-side-bundle-with-webpack-and-source-map-explorer-41096559beca#.c3t2srr8x
1818
---
1919

20-
webpack provides a Command Line Interface (CLI) to configure and interact with your build. This is mostly useful in case of early prototyping, profiling, writing npm scripts or personal customization of the build.
21-
2220
For proper usage and easy distribution of this configuration, webpack can be configured with `webpack.config.js`. Any parameters sent to the CLI will map to a corresponding parameter in the config file.
2321

24-
Have a look at the [installation guide](/guides/installation) unless you have webpack already running.
22+
Have a look at the [installation guide](/guides/installation) if you don't already have webpack installed.
2523

2624
T> The new CLI for webpack is under development. New features are being added such as the `--init` flag. [Check it out!](https://github.com/webpack/webpack-cli)
2725

src/content/api/index.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,39 @@ title: Introduction
33
sort: 1
44
---
55

6-
The following interfaces provide access to the compilation process in different ways:
6+
A variety of interfaces are available to customize the compilation process. Some features overlap between interfaces, e.g. a configuration option may be available via a CLI flag, while others exist only through a single interface. The following high-level information should get you started.
77

8-
* [CLI](/api/cli)
9-
* [Node](/api/node)
10-
* [Loaders](/api/loaders)
11-
* [Plugins](/api/plugins)
8+
9+
## CLI
10+
11+
The Command Line Interface (CLI) to configure and interact with your build. It is especially useful in the case of early prototyping and profiling. For the most part, the CLI is simply used to kick off the process using a configuration file and a few flags (e.g. `--env`).
12+
13+
[Learn more!](/api/cli)
14+
15+
16+
## Module
17+
18+
When processing modules with webpack, it is important to understand the different module syntaxes -- specifically the [methods](/api/module-methods) and [variables](/api/module-variables) -- that are supported.
19+
20+
[Learn more!](/api/module-methods)
21+
22+
23+
## Node
24+
25+
While most users can get away with just using the CLI along with a configuration file, more fine-grained control of the compilation can be achieved via the Node interface. This includes passing multiple configurations, programatically running or watching, and collecting stats.
26+
27+
[Learn more!](/api/node)
28+
29+
30+
## Loaders
31+
32+
Loaders are transformations that are applied to the source code of a module. They are written as functions that take accept source code as a parameter and return a new version of that code with tranformations applied.
33+
34+
[Learn more!](/api/loaders)
35+
36+
37+
## Plugins
38+
39+
The plugin interface provided by webpack allows users to tap directly into the compilation process. Plugins can register handlers on lifecycle hooks that run at different points in the compilation process. When each hook is executed, the plugin will have full access to the current state of the compilation.
40+
41+
[Learn more!](/api/plugins)

src/content/api/loaders.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ sort: 4
44
contributors:
55
- TheLarkInn
66
- jhnns
7-
87
---
98

10-
Loaders are transformations that are applied on the source code of a module. They are functions (running in Node.js) that take the source of a resource file as the parameter and return the new source.
11-
12-
## How to write a loader
13-
149
A loader is just a JavaScript module that exports a function. The [loader runner](https://github.com/webpack/loader-runner) calls this function and passes the result of the previous loader or the resource file into it. The `this` context of the function is filled-in by webpack and the [loader runner](https://github.com/webpack/loader-runner) with some useful methods that allow the loader (among other things) to change its invocation style to async, or get query parameters.
1510

1611
The first loader is passed one argument: the content of the resource file. The compiler expects a result from the last loader. The result should be a `String` or a `Buffer` (which is converted to a string), representing the JavaScript source code of the module. An optional SourceMap result (as JSON object) may also be passed.

src/content/api/plugins.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
22
title: Plugin API
33
group: Plugins
4-
sort: 1
4+
sort: 0
55
---
66

7-
T> For a high-level introduction to writing plugins, start with [How to write a plugin](/development/how-to-write-a-plugin).
8-
9-
webpack provides flexible and powerful customization api in the form of plugins. Using plugins, we can plug functionality into webpack. Additionally, webpack provides lifecycle hooks into which plugins can be registered. At each of these lifecycle points, webpack will run all of the registered plugins and provide them with the current state of the webpack compilation.
7+
T> For a high-level introduction to writing plugins, start with [writing a plugin](/contribute/writing-a-plugin).
108

119
Many objects in webpack extend the `Tapable` class, which exposes a `plugin` method. And with the `plugin` method, plugins can inject custom build steps. You will see `compiler.plugin` and `compilation.plugin` used a lot. Essentially, each one of these plugin calls binds a callback to fire at specific steps throughout the build process.
1210

0 commit comments

Comments
 (0)