学无先后,达者为师

网站首页 编程语言 正文

webpack5.6.0解决报The ‘mode‘ option has not been set, webpack will fallback to ‘production‘ fo的错误、问题

作者:web半晨 更新时间: 2022-06-06 编程语言


1、打包报错信息

// WARNING in configuration
// The 'mode' option has not been set, webpack will fallback to 'production' // for thisvalue. Set 'mode' option to 'development' or 'production' to enable // defaults for each environment.
// You can also set it to 'none' to disable any default behavior. Learn more: // https://webpack.js.org/concepts/mode/

2、解决方案

2.1、设置package.json

"scripts": {
	// 开发环境
	"dev": "webpack --mode development",  
	// 生产环境
	"build": "webpack --mode production",  
}

2.2、设置webpack.config.js

module.exports = {
	entry: './src/app.js',
	output: {
		path: path.resolve(__dirname, 'dist'),
		filename: 'main.js'
	},
	// 设置mode
	mode: 'development' 
}

3、相关文章

webpack4.0-解决webpack 报The ‘mode’ option has not been set, webpack will fallback to ‘production’ fo

原文链接:https://blog.csdn.net/weixin_51157081/article/details/122290431

栏目分类
最近更新