I am trying to use electron-packager to package an electron app. When packaging my app I want to ignore the entire contents of certain folders. Using the --ignore flag you can pass a regular expression to electron-packager to tell it to ignore matches.
My folder structure looks like
app
|--build
|--node_modules
|--src
index.html
main.js
package.json
Using the method from the accepted answer of this question I prepended my expression with ^ to restrict the pattern to the root level.
let execArgs = `npx electron-packager ./ "${productName}"`
+ ` --platform=win32`
+ ` --out=${outPath}`
+ ' --ignore=^/build';
execSync(execArgs);
However, electron-packager appears to still be ignoring more than just the specific folders. If I try running the packaged app I get the error Error: Cannot find module '../helpers/buildURL'. The full relative path of this file is ./node_modules/axios/lib/helpers/buildURL.js.
If I comment out the line ignoring the build folder, I no longer get the error above.
// + ' --ignore=^/build'
How can I make electron-packager ignore specific folders and their contents from the root level?
Looks like all I had to do was surround my argument in quotes.
+ ' --ignore="^/build"';
I'm not sure why this made a difference, since my argument does not include any spaces, but when I surrounded it in quotes the expression ignored only the correct files.
I always use this script to ignore files when I package an electron app
script{"electron-build":"electron-packager . MYAPP --ignore build/* }