Skip to content

Commit 376cad5

Browse files
Merge branch 'master' into issue/1933
2 parents b20a94f + 7339a8f commit 376cad5

12 files changed

+179
-102
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ starter-kits-data.json
77
.antwar
88
.vscode
99
.idea
10-
.DS_Store
10+
.DS_Store

src/content/api/cli.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ contributors:
55
- ev1stensberg
66
- simon04
77
- tbroadley
8+
- chenxsan
89
related:
910
- title: Analyzing Build Statistics
1011
url: https://survivejs.com/webpack/optimizing-build/analyzing-build-statistics/
@@ -37,7 +38,7 @@ See [configuration](/configuration) for the options in the configuration file.
3738
## Usage without config file
3839

3940
```sh
40-
webpack <entry> [<entry>] <output>
41+
webpack <entry> [<entry>] -o <output>
4142
```
4243

4344
**`<entry>`**

src/content/api/plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ different hook classes and how they work.
9696

9797
## Next Steps
9898

99-
See the [compiler hooks](https://webpack.js.org/api/compiler-hooks/) section for a detailed listing of all the available
99+
See the [compiler hooks](/api/compiler-hooks/) section for a detailed listing of all the available
100100
`compiler` hooks and the parameters they make available.

src/content/concepts/configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ T> The most important part to take away from this document is that there are man
2828

2929
The following examples below describe how webpack's configuration object can be both expressive and configurable because _it is code_:
3030

31-
## The Simplest Configuration
31+
## Simple Configuration
3232

3333
**webpack.config.js**
3434

3535
```javascript
3636
var path = require('path');
3737

3838
module.exports = {
39+
mode: 'development',
3940
entry: './foo.js',
4041
output: {
4142
path: path.resolve(__dirname, 'dist'),

src/content/configuration/configuration-languages.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import path from 'path';
3030
import webpack from 'webpack';
3131

3232
const config: webpack.Configuration = {
33+
mode: 'production',
3334
entry: './foo.js',
3435
output: {
3536
path: path.resolve(__dirname, 'dist'),
@@ -103,6 +104,7 @@ webpack = require('webpack')
103104
path = require('path')
104105

105106
config =
107+
mode: 'production'
106108
entry: './path/to/my/entry/file.js'
107109
output:
108110
path: path.resolve(__dirname, 'dist')
@@ -152,7 +154,7 @@ const CustomPlugin = config => ({
152154
});
153155

154156
export default (
155-
<webpack target="web" watch>
157+
<webpack target="web" watch mode="production">
156158
<entry path="src/index.js" />
157159
<resolve>
158160
<alias {...{

src/content/configuration/configuration-types.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ One option is to export a function from your webpack config instead of exporting
2424
-module.exports = {
2525
+module.exports = function(env, argv) {
2626
+ return {
27+
+ mode: env.production ? 'production' : 'development',
2728
+ devtool: env.production ? 'source-maps' : 'eval',
2829
plugins: [
2930
new webpack.optimize.UglifyJsPlugin({
@@ -64,11 +65,13 @@ module.exports = [{
6465
libraryTarget: 'amd'
6566
},
6667
entry: './app.js',
68+
mode: 'production',
6769
}, {
6870
output: {
6971
filename: './dist-commonjs.js',
7072
libraryTarget: 'commonjs'
7173
},
7274
entry: './app.js',
75+
mode: 'production',
7376
}]
7477
```

src/content/configuration/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ __webpack.config.js__
2929
const path = require('path');
3030
3131
module.exports = {
32+
<details><summary>[mode](/concepts/mode): "production", // "production" | "development" | "none"</summary>
33+
[mode](/concepts/mode): "production", // enable many optimizations for production builds
34+
[mode](/concepts/mode): "development", // enabled useful tools for development
35+
[mode](/concepts/mode): "none", // no defaults
36+
</details>
37+
// Chosen mode tells webpack to use its built-in optimizations accordingly.
38+
3239
<details><summary>[entry](/configuration/entry-context#entry): "./app/entry", // string | object | array</summary>
3340
[entry](/configuration/entry-context#entry): ["./app/entry1", "./app/entry2"],
3441
[entry](/configuration/entry-context#entry): {

src/content/configuration/stats.md

+36
Original file line numberDiff line numberDiff line change
@@ -37,86 +37,122 @@ For more granular control, it is possible to specify exactly what information yo
3737

3838
``` js
3939
stats: {
40+
4041
// fallback value for stats options when an option is not defined (has precedence over local webpack defaults)
4142
all: undefined,
43+
4244
// Add asset Information
4345
assets: true,
46+
4447
// Sort assets by a field
4548
// You can reverse the sort with `!field`.
4649
assetsSort: "field",
50+
4751
// Add build date and time information
4852
builtAt: true,
53+
4954
// Add information about cached (not built) modules
5055
cached: true,
56+
5157
// Show cached assets (setting this to `false` only shows emitted files)
5258
cachedAssets: true,
59+
5360
// Add children information
5461
children: true,
62+
5563
// Add chunk information (setting this to `false` allows for a less verbose output)
5664
chunks: true,
65+
5766
// Add built modules information to chunk information
5867
chunkModules: true,
68+
5969
// Add the origins of chunks and chunk merging info
6070
chunkOrigins: true,
71+
6172
// Sort the chunks by a field
6273
// You can reverse the sort with `!field`. Default is `id`.
6374
chunksSort: "field",
75+
6476
// Context directory for request shortening
6577
context: "../src/",
78+
6679
// `webpack --colors` equivalent
6780
colors: false,
81+
6882
// Display the distance from the entry point for each module
6983
depth: false,
84+
7085
// Display the entry points with the corresponding bundles
7186
entrypoints: false,
87+
7288
// Add --env information
7389
env: false,
90+
7491
// Add errors
7592
errors: true,
93+
7694
// Add details to errors (like resolving log)
7795
errorDetails: true,
96+
7897
// Exclude assets from being displayed in stats
7998
// This can be done with a String, a RegExp, a Function getting the assets name
8099
// and returning a boolean or an Array of the above.
81100
excludeAssets: "filter" | /filter/ | (assetName) => ... return true|false |
82101
["filter"] | [/filter/] | [(assetName) => ... return true|false],
102+
83103
// Exclude modules from being displayed in stats
84104
// This can be done with a String, a RegExp, a Function getting the modules source
85105
// and returning a boolean or an Array of the above.
86106
excludeModules: "filter" | /filter/ | (moduleSource) => ... return true|false |
87107
["filter"] | [/filter/] | [(moduleSource) => ... return true|false],
108+
88109
// See excludeModules
89110
exclude: "filter" | /filter/ | (moduleSource) => ... return true|false |
90111
["filter"] | [/filter/] | [(moduleSource) => ... return true|false],
112+
91113
// Add the hash of the compilation
92114
hash: true,
115+
93116
// Set the maximum number of modules to be shown
94117
maxModules: 15,
118+
95119
// Add built modules information
96120
modules: true,
121+
97122
// Sort the modules by a field
98123
// You can reverse the sort with `!field`. Default is `id`.
99124
modulesSort: "field",
125+
100126
// Show dependencies and origin of warnings/errors (since webpack 2.5.0)
101127
moduleTrace: true,
128+
102129
// Show performance hint when file size exceeds `performance.maxAssetSize`
103130
performance: true,
131+
104132
// Show the exports of the modules
105133
providedExports: false,
134+
106135
// Add public path information
107136
publicPath: true,
137+
108138
// Add information about the reasons why modules are included
109139
reasons: true,
140+
110141
// Add the source code of modules
111142
source: true,
143+
112144
// Add timing information
113145
timings: true,
146+
114147
// Show which exports of a module are used
115148
usedExports: false,
149+
116150
// Add webpack version information
117151
version: true,
152+
118153
// Add warnings
119154
warnings: true,
155+
120156
// Filter warnings to be shown (since webpack 2.4.0),
121157
// can be a String, Regexp, a function getting the warning and returning a boolean
122158
// or an Array of a combination of the above. First match wins.

src/content/guides/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Version: webpack 4.0.1
184184
Time: 3003ms
185185
Built at: 2018-2-26 22:42:11
186186
Asset Size Chunks Chunk Names
187-
bundle.js 69.6 KiB 0 [emitted] main
187+
main.js 69.6 KiB 0 [emitted] main
188188
Entrypoint main = main.js
189189
[1] (webpack)/buildin/module.js 519 bytes {0} [built]
190190
[2] (webpack)/buildin/global.js 509 bytes {0} [built]

src/content/guides/installation.md

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ npm install --save-dev webpack
2828
npm install --save-dev webpack@<version>
2929
```
3030

31+
If you're using webpack 4 or later, you'll also need to install the CLI.
32+
33+
``` bash
34+
npm install --save-dev webpack-cli
35+
```
36+
3137
Installing locally is what we recommend for most projects. This makes it easier to upgrade projects individually when breaking changes are introduced. Typically webpack is run via one or more [npm scripts](https://docs.npmjs.com/misc/scripts) which will look for a webpack installation in your local `node_modules` directory:
3238

3339
```json

src/content/index.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: webpack
66

77
<div class="splash__wrap">
88
<div class="splash__left">
9-
__app.js__
9+
__src/index.js__
1010

1111
```js
1212
import bar from './bar';
@@ -15,7 +15,7 @@ bar();
1515
```
1616
</div>
1717
<div class="splash__right">
18-
__bar.js__
18+
__src/bar.js__
1919

2020
```js
2121
export default function bar() {
@@ -30,12 +30,15 @@ export default function bar() {
3030

3131
<div class="splash__wrap">
3232
<div class="splash__left">
33-
__webpack.config.js__
33+
__[Without config](https://youtu.be/3Nv9muOkb6k?t=21293)__ or provide custom __webpack.config.js__
3434

3535
```js
36+
const path = require('path');
37+
3638
module.exports = {
37-
entry: './app.js',
39+
entry: './src/index.js',
3840
output: {
41+
path: path.resolve(__dirname, 'dist'),
3942
filename: 'bundle.js'
4043
}
4144
};
@@ -52,7 +55,7 @@ __page.html__
5255
</head>
5356
<body>
5457
...
55-
<script src="bundle.js"></script>
58+
<script src="dist/bundle.js"></script>
5659
</body>
5760
</html>
5861
```

0 commit comments

Comments
 (0)