如何在配置文件中将模式设置为开发或生产? [英] How to set mode to development or production in the config file?

查看:32
本文介绍了如何在配置文件中将模式设置为开发或生产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在迁移到 webpack 4.我们已经有了 dev/prod 配置文件.我们开始收到此警告消息:

We are migrating to webpack 4. We do have dev / prod config files already. We started getting this warning message:

WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' 
or 'production' to enable defaults for this environment.

我们可以通过在命令行中传递 --mode production 来解决这个问题,如下所示:

We can get around this by passing --mode production in the cmdline like below:

npm run webpack --mode development ...

正如 webpack 文档、博客和互联网上的其他地方所提到的.我们如何在配置文件中设置配置?简单地说一个模式:在模块下开发是行不通的.只是有点沮丧,为什么文档只是丢失...

As is mentioned on the webpack documentation, blog and everywhere else on the internet. How can we set the config in the config file? Simply putting a mode: development under modules won't work. Just a bit frustrated why the documentation is just missing...

推荐答案

我现在正在寻找相同的答案,对我来说似乎将属性添加到配置文件中.

I was looking to the same answer right now, for me it seems that adding the property to the config file do the job.

module.exports = {
  // ...
  mode: 'development'
};

这篇关于如何在配置文件中将模式设置为开发或生产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆