> For the complete documentation index, see [llms.txt](https://azr.gitbook.io/webpack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://azr.gitbook.io/webpack/shi-zhan/quan-ju-bian-liang.md).

# 全局变量

使用`DefinePlugin`来进行将包提取为文件。&#x20;

### webpack.config.js

```javascript
const { DefinePlugin } = require('webpack');


module.exports = {
  plugins: [
    new DefinePlugin({
      // 定义 NODE_ENV 环境变量为 production，以去除源码中只有开发时才需要的部分
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
  ],
};
```
