File tree Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,15 @@ T> The most important part to take away from this document is that there are man
28
28
29
29
The following examples below describe how webpack's configuration object can be both expressive and configurable because _ it is code_ :
30
30
31
- ## The Simplest Configuration
31
+ ## Simple Configuration
32
32
33
33
** webpack.config.js**
34
34
35
35
``` javascript
36
36
var path = require (' path' );
37
37
38
38
module .exports = {
39
+ mode: ' development' ,
39
40
entry: ' ./foo.js' ,
40
41
output: {
41
42
path: path .resolve (__dirname , ' dist' ),
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import path from 'path';
30
30
import webpack from ' webpack' ;
31
31
32
32
const config: webpack .Configuration = {
33
+ mode: ' production' ,
33
34
entry: ' ./foo.js' ,
34
35
output: {
35
36
path: path .resolve (__dirname , ' dist' ),
@@ -103,6 +104,7 @@ webpack = require('webpack')
103
104
path = require (' path' )
104
105
105
106
config =
107
+ mode: ' production'
106
108
entry: ' ./path/to/my/entry/file.js'
107
109
output:
108
110
path: path .resolve (__dirname , ' dist' )
@@ -152,7 +154,7 @@ const CustomPlugin = config => ({
152
154
});
153
155
154
156
export default (
155
- < webpack target= " web" watch>
157
+ < webpack target= " web" watch mode = " production " >
156
158
< entry path= " src/index.js" / >
157
159
< resolve>
158
160
< alias {... {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ One option is to export a function from your webpack config instead of exporting
24
24
- module.exports = {
25
25
+ module.exports = function(env, argv) {
26
26
+ return {
27
+ + mode: env.production ? 'production' : 'development',
27
28
+ devtool: env.production ? 'source-maps' : 'eval',
28
29
plugins: [
29
30
new webpack.optimize.UglifyJsPlugin({
@@ -64,11 +65,13 @@ module.exports = [{
64
65
libraryTarget: ' amd'
65
66
},
66
67
entry: ' ./app.js' ,
68
+ mode: ' production' ,
67
69
}, {
68
70
output: {
69
71
filename: ' ./dist-commonjs.js' ,
70
72
libraryTarget: ' commonjs'
71
73
},
72
74
entry: ' ./app.js' ,
75
+ mode: ' production' ,
73
76
}]
74
77
```
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ __webpack.config.js__
29
29
const path = require('path');
30
30
31
31
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
+
32
39
<details><summary>[entry](/configuration/entry-context#entry): "./app/entry", // string | object | array</summary>
33
40
[entry](/configuration/entry-context#entry): ["./app/entry1", "./app/entry2"],
34
41
[entry](/configuration/entry-context#entry): {
You can’t perform that action at this time.
0 commit comments