我有一个复杂的webpack配置设置(将动态设置合并到多个配置文件中),我想看看webpack使用的最终配置是什么,即所有这些和默认设置合并的结果。
如何才能做到这一点?
这对我适用于webpack 4.x:
let config = {
// ...
plugins: [
// ...
{ // anonymous plugin
apply(compiler) {
compiler.hooks.beforeRun.tapAsync('MyCustomBeforeRunPlugin', function(compiler, callback) {
// debugger
console.dir(compiler.options)
callback()
})
},
}
]
}
Run Code Online (Sandbox Code Playgroud)
取消注释该debugger语句并运行带有--inspect-brk标志(node --inspect-brk run-webpack.js)的构建时,您还可以在chrome://inspect/页面的Chrome devtools中看到它(用于检查无法序列化到控制台的函数和对象实例)。
小智 5
对我有用的还有,我在导出语句之前创建了我想要的所有配置,然后导出了一个可以控制台并返回配置的函数
module.exports = () => {
// I have two configs to export and wanted to see the rules
// you may not see the nested objects then you have to console log them
// directly
console.log(config[0].module.rules);
console.log(config[1].module.rules);
return config;
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1241 次 |
| 最近记录: |