-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Concepts): update concepts page for v4 (#1883)
This updates the Concepts page to facilitate webpack v4's options and changes.
- Loading branch information
1 parent
38faec2
commit 0c96dd5
Showing
3 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Mode | ||
sort: 4 | ||
contributors: | ||
- EugeneHlushko | ||
--- | ||
|
||
Providing the `mode` configuration option tells webpack to use its built-in optimizations accordingly. | ||
|
||
`string` | ||
|
||
## Usage | ||
|
||
Just provide the `mode` option in the config: | ||
|
||
```javascript | ||
module.exports = { | ||
mode: 'production' | ||
}; | ||
``` | ||
|
||
|
||
or pass it as a cli argument: | ||
|
||
```bash | ||
webpack --mode=production | ||
``` | ||
|
||
The following string values are supported: | ||
|
||
Option | Description | ||
--------------------- | ----------------------- | ||
`development` | Provides `process.env.NODE_ENV` with value `development`. Enables `NamedModulesPlugin`. | ||
`production` | Provides `process.env.NODE_ENV` with value `production`. Enables `UglifyJsPlugin`, `ModuleConcatenationPlugin` and `NoEmitOnErrorsPlugin`. | ||
|
||
|
||
### Mode: development | ||
|
||
|
||
```diff | ||
// webpack.production.config.js | ||
module.exports = { | ||
+ mode: 'development' | ||
- plugins: [ | ||
- new webpack.NamedModulesPlugin(), | ||
- new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("development") }), | ||
- ] | ||
} | ||
``` | ||
|
||
|
||
### Mode: production | ||
|
||
|
||
```diff | ||
// webpack.production.config.js | ||
module.exports = { | ||
+ mode: 'production', | ||
- plugins: [ | ||
- new UglifyJsPlugin(/* ... */), | ||
- new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }), | ||
- new webpack.optimize.ModuleConcatenationPlugin(), | ||
- new webpack.NoEmitOnErrorsPlugin() | ||
- ] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters