Comments (15)
But it seems, the electron-package is running before the native build and thus above ignore is of no use.
This is accurate, you need to use an afterCopy
hook to delete the artifacts you don't want from the native module build process.
/cc @malept I don't think we should do this ^^ by default as some people may want the debug artifacts. What do you think?
from forge.
@MarshallOfSound can you tell me how to ignore some dir/files using afterCopy
? I don't see any examples.
from forge.
@manikantag Not ignore really, more like delete.
Use a combination of fs.unlinkSync
and the glob
module.
from forge.
Excuse me for asking questions in this issue.
I m writing some console logs, but Forge cli output is only seen, no console logs. Where do I see them? Thanks.
from forge.
@MarshallOfSound I m not sure how to use afterCopy
.
config.forge in package.json
:
"forge": {
"afterCopy": [
"./forge-hooks.js"
]
}
forge-hooks.js:
const fs = require('fs');
function afterCopy() {
fs.unlinkSync('d:/test.txt');
}
module.exports = afterCopy
The afterCopy
hook is not working as d:\test.txt
file is not getting deleted. I m trying to go through the source (https://github.com/electron-userland/electron-forge/blob/master/src/api/package.js#L84), but no clue so far.
What is the correct way of using afterCopy
and what are the arguments?
from forge.
fs.unlinkSync('d:/test.txt');
That path looks wrong (for windows). Try this.
fs.unlinkSync('d:\\test.txt');
You can also try adding some console.log
calls to ensure that JS file is being resolved correctly.
from forge.
fs.unlinkSync('d:/test.txt');
That path looks wrong (for windows). Try this.
Node fs module will take care of it even when using /
.
from forge.
You can also try adding some console.log calls to ensure that JS file is being resolved correctly.
As I mentioned in earlier, I m not seeing any console.logs when I m using forge start
or forge package
or any forge command. Where can I see console.logs?
from forge.
Okay, I figured it out. I need use config.forge.electronPackagerConfig.afterCopy
, but not config.forge.afterCopy
.
But now, the require
is failing.
"electronPackagerConfig": {
"afterCopy": [
"./forge-hooks"
]
}
If I give absolute path, it is working. How do I give relative paths? And how do I know the packaging temp dir? what are the args for the afterCopy
method?
DEBUG log:
An unhandled rejection has occurred inside Forge:
Cannot find module './forge-hooks'
Error: Cannot find module './forge-hooks'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at C:\eapp\node_modules\electron-forge\dist\api\package.js:297:51
at Array.map (native)
at _callee4$ (C:\eapp\node_modules\electron-forge\dist\api\package.js:296:119)
at tryCatch (C:\eapp\node_modules\regenerator-runtime\runtime.js:64:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\eapp\node_modules\regenerator-runtime\runtime.js:355:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\eapp\node_modules\regenerator-runtime\runtime.js:116:21)
at GeneratorFunctionPrototype.tryCatcher (C:\eapp\node_modules\bluebird\js\release\util.js:16:23)
at PromiseSpawn._promiseFulfilled (C:\eapp\node_modules\bluebird\js\release\generators.js:97:49)
at Promise._settlePromise (C:\eapp\node_modules\bluebird\js\release\promise.js:572:26)
at Promise._settlePromise0 (C:\eapp\node_modules\bluebird\js\release\promise.js:612:10)
at Promise._settlePromises (C:\eapp\node_modules\bluebird\js\release\promise.js:691:18)
at Async._drainQueue (C:\eapp\node_modules\bluebird\js\release\async.js:133:16)
from forge.
Got the arguments: buildPath, electronVersion, pPlatform, pArch, done
.
I got these from https://github.com/electron-userland/electron-forge/blob/master/src/api/package.js#L64
I m seeing console logs when using DEBUG=electron-debug:*
.
So, now I m left with giving relative paths for afterCopy
js file.
from forge.
@manikantag The afterCopy
hooks are documented over at electron-packager
.
https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
I'm looking into the relative path issue now
from forge.
I m using https://www.npmjs.com/package/rimraf to delete build dirctory as the dir has files in it.
from forge.
[email protected]
should fix the path resolution issue, gonna close this out as the recommended solution is to use an afterCopy
hook to clean up.
from forge.
Would say that if someone can make a super generic afterCopy
hook to clean up a node_modules
directory as a separate module that would be pretty cool.
electron-packager-cleanup-hook
from forge.
With 2.7.3, it is working with relative paths. Pretty quick fix! Thanks.
from forge.
Related Issues (20)
- The installation process is stuck and the loading image is displayed. The application cannot be started.
- [PnP] Cannot find the package "electron" HOT 5
- Electron forge is showing a new Error where it cannot copy my app to /volumes dir HOT 7
- The packaged OSX or Ubuntu app doesn't work correctly if it was started from another app
- Shipping broken. EJSONPARSE error HOT 1
- Vite extension hangs on building main code
- Update Docs for cloud-based EV code signing HOT 4
- Electron-Forge - Webpack - Start - ENOSPC
- electron-forge publish hangs on "Preparing native dependencies" HOT 1
- image cannot be resolved when application is packed HOT 4
- Update to latest maintained Node.js engines
- local modules added with npm can break vite-based build HOT 1
- Win32 make from macOs
- Remove hardcoded `node_modules` HOT 1
- Vite plugin seems to preserve symlinks during packageAfterCopy hook
- Is Electron Forge too opinionated?
- "npm run start" startup exception
- npm run make error: DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.
- how to place mac app into Appliactions/{folder}/appName.app rather on /Applications after install via dmg HOT 2
- Allow passing "copyright" config to DEB and RPM makers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forge.