Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 如何停止显示网页包中的生成日志?_Webpack_Nuxt.js - Fatal编程技术网

Webpack 如何停止显示网页包中的生成日志?

Webpack 如何停止显示网页包中的生成日志?,webpack,nuxt.js,Webpack,Nuxt.js,我希望停止显示生成日志,如下所示: Hash: 5a2a3d23f88174970ed8 Version: webpack 3.12.0 Time: 22209ms Asset Size Chunks Chunk Names pages/widgets/index.51838abe9967a9e0b5ff.js 1.17 kB 10 [em

我希望停止显示生成日志,如下所示:

Hash: 5a2a3d23f88174970ed8
Version: webpack 3.12.0
Time: 22209ms
                                         Asset       Size  Chunks                    Chunk Names
   pages/widgets/index.51838abe9967a9e0b5ff.js    1.17 kB      10  [emitted]         pages/widgets/index
                       img/icomoon.7f1da5a.svg    5.38 kB          [emitted]         
                     fonts/icomoon.2d429d6.ttf    2.41 kB          [emitted]         
           img/fontawesome-webfont.912ec66.svg     444 kB          [emitted]  [big]  
         fonts/fontawesome-webfont.b06871f.ttf     166 kB          [emitted]         
                        img/mobile.8891a7c.png    39.6 kB          [emitted]         
                   img/play_button.6b15900.png    14.8 kB          [emitted]         
                  img/keyword-back.f95e10a.jpg    43.4 kB          [emitted]         
                    fonts/icomoon.16db67c.woff    2.49 kB          [emitted]         
                     fonts/icomoon.2fcbf50.eot    2.58 kB          [emitted]         
         fonts/fontawesome-webfont.674f50d.eot     166 kB          [emitted]         
        fonts/fontawesome-webfont.fee66e7.woff      98 kB          [emitted]         

.
.
.
我使用
ava
运行测试。但是这些日志让我很烦。我试图在
numxt.config.js
中设置webpack
stats
config,但它不起作用。有人能帮忙吗

// Does not work
{
  ...
  build: {
    ...
    extend (config, { isClient }) {
      ...
      if (process.env.NODE_ENV === 'test') {
        config.stats = 'errors-only'
      }
    }
  }
 ...
}

更新:以下内容可以隐藏资产日志,但仍显示警告:

// Works, but does not hide warnings
{
  ...
  build: {
    stats: process.env.NODE_ENV === 'test' ? 'errors-only' {
      chunks: false,
      children: false,
      modules: false,
      colors: true,
      assets: true,
      warnings: true,
      errors: true,
      excludeAssets: [
        /.map$/,
        /index\..+\.html$/,
        /vue-ssr-client-manifest.json/
      ]
    },
    ...
  }
 ...
}
 WARNING  Compiled with 2 warnings

 warning  

asset size limit: The following asset(s) exceed the recommended size limit (300 kB).
This can impact web performance.
Assets: 
  img/fontawesome-webfont.912ec66.svg (444 kB)
  vendor.4db9bb219a2a9c02d939.js (726 kB)
  app.f14777ec0017fec245a3.js (546 kB)

 warning  

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (1 MB). This can impact web performance.
Entrypoints:
  app (1.27 MB)
      manifest.4eb49c6cde9aa836f4d4.js
      vendor.4db9bb219a2a9c02d939.js
      app.f14777ec0017fec245a3.js
但这并没有隐藏警告:

// Works, but does not hide warnings
{
  ...
  build: {
    stats: process.env.NODE_ENV === 'test' ? 'errors-only' {
      chunks: false,
      children: false,
      modules: false,
      colors: true,
      assets: true,
      warnings: true,
      errors: true,
      excludeAssets: [
        /.map$/,
        /index\..+\.html$/,
        /vue-ssr-client-manifest.json/
      ]
    },
    ...
  }
 ...
}
 WARNING  Compiled with 2 warnings

 warning  

asset size limit: The following asset(s) exceed the recommended size limit (300 kB).
This can impact web performance.
Assets: 
  img/fontawesome-webfont.912ec66.svg (444 kB)
  vendor.4db9bb219a2a9c02d939.js (726 kB)
  app.f14777ec0017fec245a3.js (546 kB)

 warning  

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (1 MB). This can impact web performance.
Entrypoints:
  app (1.27 MB)
      manifest.4eb49c6cde9aa836f4d4.js
      vendor.4db9bb219a2a9c02d939.js
      app.f14777ec0017fec245a3.js

以下是对您的网页配置的建议:

module.exports = {
 devServer: {
  stats: {
    colors: true,
    hash: false,
    version: false,
    timings: false,
    assets: false,
    chunks: false,
    modules: false,
    reasons: false,
    children: false,
    source: false,
    errors: false,
    errorDetails: false,
    warnings: false,
    publicPath: false
  }
 }
}
要禁用的关键功能是
散列
版本
计时
资产

这将减少构建时间并抑制日志记录


注:此建议来自。不过,我不能将这个问题标记为重复问题,因为它有悬赏。:)

你可以这样做

build: {

          stats: process.env.NODE_ENV === 'test' ? 'errors-only' : { // default config here for non test build. Nuxt default could be seen here
 https://github.com/nuxt/nuxt.js/blob/567dc860c1393ccf0e849b032b69edddd5b6b7bb/lib/common/nuxt.config.js#L93
 }

         ...
        }

这不是关于网页包。是关于nuxt的。Nuxt有一个自定义的.erbpack生成器,并自己应用webpack配置哦,我想Nuxt可以继承一个基本的webpack配置。我的错误,它起作用了!除了
超出建议的大小限制
警告之外,它确实隐藏了所有打印的资源。他们应该在文档中提到这些配置。您知道如何隐藏警告吗?这会让你得到答案complete@Dipu您可以提供完整配置,而不是仅提供错误,您可以单独设置,例如警告:false。或者您可以将其设置为False。我使用完整配置进行了测试,但它不起作用。警告是没有关系的what@Dipu可能是,您可以尝试使用edge,它将很快发布并且已经稳定