Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: align DefinePlugin with #7108 in v0.x #8582

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions website/docs/en/plugins/webpack/define-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ if (!BROWSER_SUPPORTS_HTML5) require('html5shiv');
When defining values for `process` prefer `'process.env.NODE_ENV': JSON.stringify('production')` over `process: { env: { NODE_ENV: JSON.stringify('production') } }`. Using the latter will overwrite the `process` object which can break compatibility with some modules that expect other values on the process object to be defined.
:::

:::tip
Note that because the plugin does a direct text replacement, the value given to it must include **actual quotes** inside of the string itself. Typically, this is done either with alternate quotes, such as `'"production"'`, or by using `JSON.stringify('production')`.
:::

```js
if (!PRODUCTION) {
console.log('Debug info');
Expand Down
4 changes: 0 additions & 4 deletions website/docs/zh/plugins/webpack/define-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ if (!BROWSER_SUPPORTS_HTML5) require('html5shiv');
在为 `process` 定义值时,推荐使用 `'process.env.NODE_ENV': JSON.stringify('production')` 而不是 `process: { env: { NODE_ENV: JSON.stringify('production') } }`。使用后者会重写 `process` 对象,这可能会破坏对某些模块的兼容性,这些模块期望 process 对象上的其他值被定义。
:::

:::tip 提示
请注意,由于插件直接执行文本替换,因此提供给它的值必须包含字符串内部的实际引号。通常,这是通过使用交替引号,如 `'"production"'`,或使用 `JSON.stringify('production')` 来完成。
:::

```js
if (!PRODUCTION) {
console.log('Debug info');
Expand Down
Loading