You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/concepts/modules.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,6 @@ The webpack community has built _loaders_ for a wide variety of popular language
40
40
*[Less](http://lesscss.org)
41
41
*[Stylus](http://stylus-lang.com)
42
42
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.
44
44
45
45
For a full list, see [**the list of loaders**](/loaders) or [**write your own**](/api/loaders).
Copy file name to clipboardExpand all lines: content/concepts/output.md
+37-31Lines changed: 37 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,34 +2,39 @@
2
2
title: Output
3
3
sort: 3
4
4
contributors:
5
-
- TheLarkInn
5
+
- TheLarkInn
6
6
---
7
7
8
8
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.
9
9
10
10
If you use any hashing (`[hash]` or `[chunkhash]`), make sure to have a consistent ordering of modules. Use the `OccurrenceOrderPlugin` or `recordsPath`.
11
11
12
-
##Usage
12
+
# Usage
13
13
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.
15
19
16
20
**webpack.config.js**
17
21
18
22
```javascript
19
23
constconfig= {
20
24
output: {
21
-
filename:'bundle.js'
25
+
filename:'bundle.js',
26
+
output:'/home/proj/public/assets'
22
27
}
23
28
};
24
29
25
30
module.exports= config;
26
31
```
27
32
28
-
##Options
33
+
# Options
29
34
30
35
The following is a list of values you can pass to the `output` property.
31
36
32
-
###`output.chunkFilename`
37
+
## `output.chunkFilename`
33
38
34
39
The filename of non-entry chunks as a relative path inside the `output.path` directory.
35
40
@@ -41,7 +46,7 @@ The filename of non-entry chunks as a relative path inside the `output.path` dir
41
46
42
47
`[chunkhash]` is replaced by the hash of the chunk.
43
48
44
-
###`output.crossOriginLoading`
49
+
## `output.crossOriginLoading`
45
50
46
51
This option enables cross-origin loading of chunks.
47
52
@@ -57,10 +62,9 @@ For more information on cross-origin loading see [MDN](https://developer.mozilla
57
62
58
63
> Default: `false`
59
64
60
-
> see also [[library and externals]]
61
-
> see also [[Development Tools]]
65
+
> see also [[library and externals]] see also [[Development Tools]]
62
66
63
-
###`output.devtoolLineToLine`
67
+
## `output.devtoolLineToLine`
64
68
65
69
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.
66
70
@@ -70,12 +74,13 @@ An object `{test, include, exclude}` similar to `module.loaders` enables it for
70
74
71
75
> Default: `false`
72
76
73
-
###`output.filename`
77
+
## `output.filename`
74
78
75
79
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.
76
80
77
81
**single entry**
78
-
```javascript
82
+
83
+
```javascript
79
84
{
80
85
entry:'./src/app.js',
81
86
output: {
@@ -97,7 +102,7 @@ If your configuration creates more than a single "chunk" (as with multiple entry
97
102
98
103
`[chunkhash]` is replaced by the hash of the chunk.
99
104
100
-
```javascript
105
+
```javascript
101
106
{
102
107
entry: {
103
108
app:'./src/app.js',
@@ -112,7 +117,7 @@ If your configuration creates more than a single "chunk" (as with multiple entry
112
117
// writes to disk: ./build/app.js, ./build/search.js
113
118
```
114
119
115
-
###`output.hotUpdateChunkFilename`
120
+
## `output.hotUpdateChunkFilename`
116
121
117
122
The filename of the Hot Update Chunks. They are inside the `output.path` directory.
118
123
@@ -122,35 +127,35 @@ The filename of the Hot Update Chunks. They are inside the `output.path` directo
122
127
123
128
> Default: `"[id].[hash].hot-update.js"`
124
129
125
-
###`output.hotUpdateFunction`
130
+
## `output.hotUpdateFunction`
126
131
127
132
The JSONP function used by webpack for async loading of hot update chunks.
128
133
129
134
> Default: `"webpackHotUpdate"`
130
135
131
-
###`output.hotUpdateMainFilename`
136
+
## `output.hotUpdateMainFilename`
132
137
133
138
The filename of the Hot Update Main File. It is inside the `output.path` directory.
134
139
135
140
`[hash]` is replaced by the hash of the compilation. (The last hash stored in the records)
136
141
137
142
> Default: `"[hash].hot-update.json"`
138
143
139
-
###`output.jsonpFunction`
144
+
## `output.jsonpFunction`
140
145
141
146
The JSONP function used by webpack for asnyc loading of chunks.
142
147
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.
144
149
145
150
> Default: `"webpackJsonp"`
146
151
147
-
###`output.library`
152
+
## `output.library`
148
153
149
154
If set, export the bundle as library. `output.library` is the name.
150
155
151
156
Use this if you are writing a library and want to publish it as single file.
152
157
153
-
###`output.libraryTarget`
158
+
## `output.libraryTarget`
154
159
155
160
Which format to export the library:
156
161
@@ -170,48 +175,49 @@ Which format to export the library:
170
175
171
176
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`).
172
177
173
-
###`output.path`
178
+
## `output.path`
174
179
175
180
The output directory as an **absolute path** (required).
176
181
177
182
`[hash]` is replaced by the hash of the compilation.
178
183
179
-
180
184
**config.js**
181
185
182
-
```javascript
186
+
```javascript
183
187
output: {
184
-
path:"/home/proj/public/assets",
185
-
publicPath:"/assets/"
188
+
path:"/home/proj/public/assets",
189
+
publicPath:"/assets/"
186
190
}
187
191
```
188
192
189
193
**index.html**
190
-
```html
194
+
195
+
```html
191
196
<head>
192
197
<linkhref="/assets/spinner.gif"/>
193
198
</head>
194
199
```
200
+
195
201
And a more complicated example of using a CDN and hashes for assets.
**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.
207
213
208
-
```javascript
214
+
```javascript
209
215
__webpack_public_path__ = myRuntimePublicPath
210
216
211
217
// rest of your application entry
212
218
```
213
219
214
-
###`output.sourceMapFilename`
220
+
## `output.sourceMapFilename`
215
221
216
222
The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
Copy file name to clipboardExpand all lines: content/concepts/plugins.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ They also serve the purpose of doing **anything else** that a [loader](/concepts
12
12
13
13
## Anatomy
14
14
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.
Copy file name to clipboardExpand all lines: content/concepts/targets.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,11 @@ module.exports = {
21
21
};
22
22
```
23
23
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
+
24
26
Each _target_ has a variety of deployment/environment specific additions, support to fit its needs. See what [targets are available](/configuration/target).
25
27
26
-
?> We should expand on this further. What specifically is included.
28
+
?>Further expansion for other popular target values
0 commit comments