Skip to content

Commit e7530ab

Browse files
authored
Merge pull request #690 from rouzbeh84/concepts-tweaking
Concepts tweaking
2 parents 496e4d4 + 36e6fa9 commit e7530ab

File tree

7 files changed

+47
-39
lines changed

7 files changed

+47
-39
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ npm-debug.log
33
build
44
generated
55
.antwar
6-

content/concepts/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ In the example below JSX (React JavaScript Markup) and Babel are used to create
158158
```javascript
159159
import h from 'jsxobj';
160160

161-
// example of an import'd plugin
161+
// example of an imported plugin
162162
const CustomPlugin = config => ({
163163
...config,
164164
name: 'custom-plugin'

content/concepts/hot-module-replacement.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ store them in a JSON file.
4747
### From The Module View
4848

4949
HMR is an opt-in feature that only affects modules containing HMR code. One example
50-
would be patching styling through the [style-loder](https://github.com/webpack/style-loader).
50+
would be patching styling through the [style-loader](https://github.com/webpack/style-loader).
5151
In order for patching to work, style-loader implements the HMR interface; when it
5252
receives an update through HMR, it replaces the old styles with the new ones.
5353

@@ -88,8 +88,9 @@ You can use it in development as a LiveReload replacement.
8888
hot mode in which it tries to update with HMR before trying to reload the whole page. See how
8989
to implement [HMR with React](/guides/hmr-react) as an example.
9090

91-
Some loaders already generate modules that are hot-updateable. For example, the `style-loader`
91+
92+
Some loaders already generate modules that are hot-updatable. For example, the `style-loader`
9293
can swap out a page's stylesheets. For modules like this, you don't need to do anything special.
9394

9495
webpack's power lies in its customizability, and there are *many* ways of configuring HMR
95-
depending on the needs of a particular project.
96+
depending on the needs of a particular project.

content/concepts/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ The webpack community has built _loaders_ for a wide variety of popular language
4040
* [Less](http://lesscss.org)
4141
* [Stylus](http://stylus-lang.com)
4242

43-
And many others! Overall, webpack provides a powerful and rich API for customization that allows one to use webpack for **any stack**, while staying **unopinionated** about your development, testing, and production workflows.
43+
And many others! Overall, webpack provides a powerful and rich API for customization that allows one to use webpack for **any stack**, while staying **non-opinionated** about your development, testing, and production workflows.
4444

4545
For a full list, see [**the list of loaders**](/loaders) or [**write your own**](/api/loaders).

content/concepts/output.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,39 @@
22
title: Output
33
sort: 3
44
contributors:
5-
- TheLarkInn
5+
- TheLarkInn
66
---
77

88
Options affecting the output of the compilation. `output` options tell Webpack how to write the compiled files to disk. Note, that while there can be multiple `entry` points, only one `output` configuration is specified.
99

1010
If you use any hashing (`[hash]` or `[chunkhash]`), make sure to have a consistent ordering of modules. Use the `OccurrenceOrderPlugin` or `recordsPath`.
1111

12-
## Usage
12+
# Usage
1313

14-
To set the `output` property, you simply set the output value in your webpack config:
14+
The minimum requirements for the `output` property in your webpack config is to set its value to an object including the following two things :
15+
16+
Your preferred `filename` of the compiled file: `// main.js || bundle.js || index.js`
17+
18+
An [`output.path`](#output-path) as an **absolute path** for what directory you prefer it to go in once bundled.
1519

1620
**webpack.config.js**
1721

1822
```javascript
1923
const config = {
2024
output: {
21-
filename: 'bundle.js'
25+
filename: 'bundle.js',
26+
output: '/home/proj/public/assets'
2227
}
2328
};
2429

2530
module.exports = config;
2631
```
2732

28-
## Options
33+
# Options
2934

3035
The following is a list of values you can pass to the `output` property.
3136

32-
### `output.chunkFilename`
37+
## `output.chunkFilename`
3338

3439
The filename of non-entry chunks as a relative path inside the `output.path` directory.
3540

@@ -41,7 +46,7 @@ The filename of non-entry chunks as a relative path inside the `output.path` dir
4146

4247
`[chunkhash]` is replaced by the hash of the chunk.
4348

44-
### `output.crossOriginLoading`
49+
## `output.crossOriginLoading`
4550

4651
This option enables cross-origin loading of chunks.
4752

@@ -57,10 +62,9 @@ For more information on cross-origin loading see [MDN](https://developer.mozilla
5762

5863
> Default: `false`
5964
60-
> see also [[library and externals]]
61-
> see also [[Development Tools]]
65+
> see also [[library and externals]] see also [[Development Tools]]
6266
63-
### `output.devtoolLineToLine`
67+
## `output.devtoolLineToLine`
6468

6569
Enable line-to-line mapped mode for all/specified modules. Line-to-line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. It's a performance optimization. Only use it if your performance needs to be better and you are sure that input lines match which generated lines.
6670

@@ -70,12 +74,13 @@ An object `{test, include, exclude}` similar to `module.loaders` enables it for
7074

7175
> Default: `false`
7276
73-
### `output.filename`
77+
## `output.filename`
7478

7579
Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written. `filename` is used solely for naming the individual files.
7680

7781
**single entry**
78-
``` javascript
82+
83+
```javascript
7984
{
8085
entry: './src/app.js',
8186
output: {
@@ -97,7 +102,7 @@ If your configuration creates more than a single "chunk" (as with multiple entry
97102

98103
`[chunkhash]` is replaced by the hash of the chunk.
99104

100-
``` javascript
105+
```javascript
101106
{
102107
entry: {
103108
app: './src/app.js',
@@ -112,7 +117,7 @@ If your configuration creates more than a single "chunk" (as with multiple entry
112117
// writes to disk: ./build/app.js, ./build/search.js
113118
```
114119

115-
### `output.hotUpdateChunkFilename`
120+
## `output.hotUpdateChunkFilename`
116121

117122
The filename of the Hot Update Chunks. They are inside the `output.path` directory.
118123

@@ -122,35 +127,35 @@ The filename of the Hot Update Chunks. They are inside the `output.path` directo
122127

123128
> Default: `"[id].[hash].hot-update.js"`
124129
125-
### `output.hotUpdateFunction`
130+
## `output.hotUpdateFunction`
126131

127132
The JSONP function used by webpack for async loading of hot update chunks.
128133

129134
> Default: `"webpackHotUpdate"`
130135
131-
### `output.hotUpdateMainFilename`
136+
## `output.hotUpdateMainFilename`
132137

133138
The filename of the Hot Update Main File. It is inside the `output.path` directory.
134139

135140
`[hash]` is replaced by the hash of the compilation. (The last hash stored in the records)
136141

137142
> Default: `"[hash].hot-update.json"`
138143
139-
### `output.jsonpFunction`
144+
## `output.jsonpFunction`
140145

141146
The JSONP function used by webpack for asnyc loading of chunks.
142147

143-
A shorter function may reduce the filesize a bit. Use a different identifier when having multiple webpack instances on a single page.
148+
A shorter function may reduce the file size a bit. Use a different identifier when having multiple webpack instances on a single page.
144149

145150
> Default: `"webpackJsonp"`
146151
147-
### `output.library`
152+
## `output.library`
148153

149154
If set, export the bundle as library. `output.library` is the name.
150155

151156
Use this if you are writing a library and want to publish it as single file.
152157

153-
### `output.libraryTarget`
158+
## `output.libraryTarget`
154159

155160
Which format to export the library:
156161

@@ -170,48 +175,49 @@ Which format to export the library:
170175
171176
If `output.library` is not set, but `output.libraryTarget` is set to a value other than `var`, every property of the exported object is copied (Except `amd`, `commonjs2` and `umd`).
172177

173-
### `output.path`
178+
## `output.path`
174179

175180
The output directory as an **absolute path** (required).
176181

177182
`[hash]` is replaced by the hash of the compilation.
178183

179-
180184
**config.js**
181185

182-
``` javascript
186+
```javascript
183187
output: {
184-
path: "/home/proj/public/assets",
185-
publicPath: "/assets/"
188+
path: "/home/proj/public/assets",
189+
publicPath: "/assets/"
186190
}
187191
```
188192

189193
**index.html**
190-
``` html
194+
195+
```html
191196
<head>
192197
<link href="/assets/spinner.gif"/>
193198
</head>
194199
```
200+
195201
And a more complicated example of using a CDN and hashes for assets.
196202

197203
**config.js**
198204

199-
``` javascript
205+
```javascript
200206
output: {
201-
path: "/home/proj/cdn/assets/[hash]",
202-
publicPath: "http://cdn.example.com/assets/[hash]/"
207+
path: "/home/proj/cdn/assets/[hash]",
208+
publicPath: "http://cdn.example.com/assets/[hash]/"
203209
}
204210
```
205211

206212
**Note:** In cases when the eventual `publicPath` of output files isn't known at compile time, it can be left blank and set dynamically at runtime in the entry point file. If you don't know the `publicPath` while compiling, you can omit it and set `__webpack_public_path__` on your entry point.
207213

208-
``` javascript
214+
```javascript
209215
__webpack_public_path__ = myRuntimePublicPath
210216

211217
// rest of your application entry
212218
```
213219

214-
### `output.sourceMapFilename`
220+
## `output.sourceMapFilename`
215221

216222
The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
217223

content/concepts/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ They also serve the purpose of doing **anything else** that a [loader](/concepts
1212

1313
## Anatomy
1414

15-
A webpack **plugin** is a JavaScript object that has an `apply` property. This `apply` property is called by the webpack compiler, giving access to the **entire** compilation lifecycle.
15+
A webpack **plugin** is a JavaScript object that has an [`apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) property. This `apply` property is called by the webpack compiler, giving access to the **entire** compilation lifecycle.
1616

1717
**ConsoleLogOnBuildWebpackPlugin.js**
1818

content/concepts/targets.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ module.exports = {
2121
};
2222
```
2323

24+
In the example above, using `node` webpack will compile for usage in a Node.js-like environment (uses Node.js `require` to load chunks and not touch any built in modules like `fs` or `path`).
25+
2426
Each _target_ has a variety of deployment/environment specific additions, support to fit its needs. See what [targets are available](/configuration/target).
2527

26-
?> We should expand on this further. What specifically is included.
28+
?>Further expansion for other popular target values
2729

2830
## Multiple Targets
2931

0 commit comments

Comments
 (0)