Skip to content

Commit d6812de

Browse files
EugeneHlushkomontogeek
authored andcommitted
docs(configuration) Update snippets to comply with webpack v4+ (#1905)
* docs(configuration) Update snippets to comply with webpack v4+ * Expand mode for more info
1 parent a60c9c9 commit d6812de

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/content/concepts/configuration.md

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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): {

0 commit comments

Comments
 (0)