如何通过 webpack 从生产构建中删除 cpp 文件?

How to remove cpp files from production build via webpack?

我使用 webpack 4 and electron-builder 来捆绑和构建我的 Electron 应用程序。我注意到 app.asar 包的 node_modules 目录中的本机节点模块仍然包含它们的 C++ 源文件。

有没有办法从构建步骤中排除某些文件扩展名?

electron-builder 可以排除 package.json.

files 部分中的文件

Default pattern / is not added to your custom if some of your patterns is not ignore (i.e. not starts with !). package.json and /node_modules// (only production dependencies will be copied) is added to your custom in any case. All default ignores are added in any case — you don’t need to repeat it if you configure own patterns.

例子

"!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}",