带有作为配置提供的数组的 Webpack [英] Webpack with an array provided as config

查看:33
本文介绍了带有作为配置提供的数组的 Webpack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个 webpack starter kit https://github.com/webpack/react-starter 中,我看到了 webpack.production.config.js 模块不仅导出配置对象,还导出配置对象数组:

In this webpack starter kit https://github.com/webpack/react-starter I see the webpack.production.config.js module does not export only a config object but an array of config objects instead:

module.exports = [
    require("./make-webpack-config")({
        // commonsChunk: true,
        longTermCaching: true,
        separateStylesheet: true,
        minimize: true
        // devtool: "source-map"
    }),
    require("./make-webpack-config")({
        prerender: true
    })
];

在这种情况下,当提供多个配置对象时会发生什么?webpack 的文档中没有提到它

What will happen in this case, when multiple config objects are provided? It isn't mentioned in webpack's docs

推荐答案

传递数组启用 Webpack 的多编译器模式.这只是一种一次性运行多次 Webpack 的方法.例如,如果您正在制作 Chrome &Firefox 扩展,您可以使用多编译器同时创建两者.

Passing an array enables Webpack's multi-compiler mode. It's just a way to run Webpack multiple times in one pass. For instance, if you're making a Chrome & Firefox extension, you could use the multi-compiler to create both at once.

Webpack 多编译器示例使用移动/桌面包.

这篇关于带有作为配置提供的数组的 Webpack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆