Skip to content

Commit 2e39e0b

Browse files
committed
production-build: drop incorrect part
`-p` does not set `NODE_ENV` in the build script, see webpack/webpack#2537
1 parent ffdde0b commit 2e39e0b

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

content/guides/production-build.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,7 @@ Running `webpack -p` (or `--define process.env.NODE_ENV="production"`) defines t
5252

5353
Technically, `NODE_ENV` is a system environment variable that Node exposes into running scripts. It is used by convention to determine development-vs-production behavior, by both server tools, build scripts, and client-side libraries.
5454

55-
On one side, this allows you to conditionally modify the build configuration, for instance change the [output filename](/configuration/output/#output-filename):
56-
57-
```js
58-
// webpack.config.js
59-
const webpack = require('webpack');
60-
61-
module.exports = {
62-
/*...*/
63-
output: {
64-
filename: process.env.NODE_ENV === 'production' ? '[name].[hash].bundle.js' : '[name].bundle.js'
65-
}
66-
};
67-
```
68-
69-
Secondly, this invokes the [`DefinePlugin`](/plugins/define-plugin), which perform search-and-replace operations on the original source code. Any occurrence of `process.env.NODE_ENV` in the imported code is replaced by by `"production"`. Thus, checks like `if (process.env.NODE_ENV !== 'production') console.log('...')` are evaluated to `if (false) console.log('...')` and finally minified away using `UglifyJS`.
55+
This invokes the [`DefinePlugin`](/plugins/define-plugin), which perform search-and-replace operations on the original source code. Any occurrence of `process.env.NODE_ENV` in the imported code is replaced by by `"production"`. Thus, checks like `if (process.env.NODE_ENV !== 'production') console.log('...')` are evaluated to `if (false) console.log('...')` and finally minified away using `UglifyJS`.
7056

7157
## The manual way: Configuring webpack for multiple environments
7258

0 commit comments

Comments
 (0)