npm run asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).

介绍


使用webpack4打包时,运行npm run build:结果报错,提示
npm run build: WARNING in asset size limit: The following asset(s) exceed the recommended size limit。提示入口文件过大,webpack打包后的生成文件和入口文件体积过大,超过了默认值。

报错内容


asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.

leenhem@leenhem-Thinkpad-T440P:~/code/vue-element-admin$ npm run prod

> vue-element-admin@4.4.0 prod
> vue-cli-service serve --mode production

 INFO  Starting development server...


 WARNING  Compiled with 2 warnings                                                                                                                          上午10:37:26

 warning  

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  static/css/app.e44a11ae.css (248 KiB)
  static/js/chunk-3d48ca62.afc066a9.js (1.33 MiB)
  static/js/chunk-5164a781.b8c02a89.js (890 KiB)
  static/js/chunk-7801aabc.8490b9cb.js (794 KiB)
  static/js/chunk-elementUI.611e9551.js (659 KiB)
  static/js/chunk-libs.824d12a4.js (396 KiB)

 warning  

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  app (1.4 MiB)
      static/js/chunk-elementUI.611e9551.js
      static/css/chunk-libs.3dfb7769.css
      static/js/chunk-libs.824d12a4.js
      static/css/app.e44a11ae.css
      static/js/app.1e6fd036.js



  App running at:
  - Local:   http://localhost:9527/ 
  - Network: http://172.25.42.35:9527/

  App is served in production mode.
  Note this is for preview or E2E testing only.

解决方法


在vue.config.js下配置 configureWebpack
将入口文件和资源文件最大值调大就不会报错了

  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    performance: {
	    //入口起点的最大体积
      maxEntrypointSize: 50000000,
	    //生成文件的最大体积
      maxAssetSize: 30000000,
    }
}

版权声明:本文为作者原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原创文章,作者:老C,如若转载,请注明出处:https://www.code404.icu/1404.html

发表评论

登录后才能评论