npm run build: WARNING in asset size limit: The following asset(s) exceed the recommended size limit

vue项目 npm run build 时,有时回报如下错误: 

错误原因,资源(asset)和入口起点超过指定文件限制,需要在 vue.config.js 文件内做如下配置:

module.exports = {
    //webpack配置
	configureWebpack: {
	    //关闭 webpack 的性能提示
	    performance: {
		    hints:false
	    }

	    //或者

	    //警告 webpack 的性能提示
	    performance: {
	    	hints:'warning',
	    	//入口起点的最大体积
	    	maxEntrypointSize: 50000000,
	    	//生成文件的最大体积
	    	maxAssetSize: 30000000,
	    	//只给出 js 文件的性能提示
	    	assetFilter: function(assetFilename) {
	    		return assetFilename.endsWith('.js');
	    	}
	    }
    }
}

详细配置可见 webpack 官网:https://www.webpackjs.com/configuration/performance/

猜你喜欢

转载自blog.csdn.net/yun_hou/article/details/87818475
今日推荐