问题描述
我正在尝试打包我的电子应用,这需要mqtt和node-notifier模块。
所以我想做的是排除除它们之外的所有node_modules。
I'm try to packaging my electron app, and it requires mqtt and node-notifier module.So I want to do is exclude all node_modules except them.
让我们假设我想从包装中排除这些文件:
Let's assume that I want to exclude these files from packaging:
- npm-debug
- gulpfile.js
- .vscode
因此设置--ignore选项,例如:
So setting --ignore option like this:
--ignore='npm-debug|gulpfile\.js|\.vscode'
工作正常。但是除了排除mqtt和node-notifier以外的node_modules之外,我不知道如何制作正则表达式!
working fine. But additionally excluding node_modules except mqtt and node-notifier, I don't know how to make regex!
--ignore='npm-debug|gulpfile\.js|\.vscode|^((?!node_modules/mqtt).)$' // NOT WORKING
仅检查node_modules,/ ^((?! node_modules / mqtt)。)$ /是可行的,但是将它们组合成单个regex行,则不起作用。
Only checking node_modules, /^((?!node_modules/mqtt).)$/ is work, but combine them into single regex line, it's not working.
我知道我的正则表达式是错误的,但是我尝试了正则表达式字符和我的想象力的每种组合,每次尝试都失败了,并且在Google上找不到任何解决方案。
I know my regex was wrong, but I tried every combination of regex characters and my imagination, every attempt was failed and couldn't found any solution on google.
这是,您可以看到我被困在哪里。
This is Regex Testing site, you can see where am I stucked.
任何建议将不胜感激。谢谢!
Any advice will be very appreciated. Thanks!
推荐答案
来自包装商
来自电子包装商关于-修剪
标志
From electron-packager API page about --prune
flag
您应该能够简单地将除 mqtt
以外的所有软件包放在 devDependencies中
并运行打包程序
You should be able to simply put all packages except mqtt
in devDependencies
and run packaging
这篇关于在Electron中,如何仅将特定的node_modules包含在electronic-packager中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!