Home > Mobile >  How to remove cpp files from production build via webpack?
How to remove cpp files from production build via webpack?

Time:12-25

I use webpack 4 and electron-builder to bundle and build my Electron app. I noticed that native node modules inside the node_modules directory of the app.asar bundle still contain their C source files.

Is there a way to exclude certain file extensions from the build step?

CodePudding user response:

electron-builder can exclude files in the files section of your package.json.

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.

Example

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