【问题标题】:chainWebpack - how to set infrastructureLoggingchainWebpack - 如何设置基础设施Logging
【发布时间】:2021-05-04 11:55:57
【问题描述】:

我在vue.config.js 中有chainWebpack 部分。我

chainWebpack: config => {
    // Add "node_modules" alias
    config.resolve.alias
        .set('node_modules', path.join(__dirname, './node_modules'));

    config.devtool('source-map');
    // Do not remove whitespaces
    config.module.rule('vue')
        .use('vue-loader')
        .loader('vue-loader')
        .tap(options => {
            options.compilerOptions.preserveWhitespace = true
            return options
        })
}

我想包含infrastructureLogging 部分以将日志重定向到stdout 而不是stderr:

module.exports = {
  //...
  infrastructureLogging: {
    stream: process.stdout,
  },
};

如何在使用chainWebpack 部分时做到这一点?

【问题讨论】:

    标签: javascript vue.js webpack webpack-chain


    【解决方案1】:

    webpack-chain(由chainWebpack 使用)似乎不支持infrastructureLogging 的API。

    但是,您可以使用 configureWebpack 将该选项传递给 Webpack:

    module.exports = {
      configureWebpack: {
        infrastructureLogging: {
          stream: process.stdout,
        },
      }
    }
    

    注意chainWebpack 和configureWebpack 可以一起使用。使用 vue inspect 命令查看生成的 Webpack 配置。

    【讨论】:

      猜你喜欢
      • 2020-05-22
      • 2010-09-18
      • 2016-04-26
      • 1970-01-01
      • 2023-03-20
      • 2011-06-19
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多