Search code examples
javascriptvue.jswebpackwebpack-chain

chainWebpack - how to set infrastructureLogging


I have chainWebpack section in vue.config.js. I

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
        })
}

I want to include infrastructureLogging section to redirect logging to stdout instead of stderr:

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

How can i do that in using chainWebpack section?


Solution

  • webpack-chain (used by chainWebpack) seems to not support an API for infrastructureLogging.

    However, you could use configureWebpack to pass that option to Webpack:

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

    Note chainWebpack and configureWebpack can be used together. Use the vue inspect command to see the resulting Webpack config.