-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add docs about how to manually load app deps (#473)
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
> Important: This approach must be used only in development environment. | ||
> Since the release version of your application the `app` directory should self contain all used files. | ||
In case on development environment your app runs the main process (executed by electron) not inside the `/app` folder. You may need to load the `/app` dependencies manually. Because the app dependencies are be placed at `/app/node_modules` and your main process that is running in a different directory will not have access by default to that directory. | ||
|
||
Instead of duplicating the app dependencies in the development `package.json` it is possible to make the electron main process load the app dependencies manually with an approach like this: | ||
|
||
```js | ||
// Given this file is: /src/browser/main.js | ||
|
||
var path = require('path'); | ||
|
||
var devMode = (process.argv || []).indexOf('--dev') !== -1; | ||
|
||
if (devMode) { | ||
// load the app dependencies | ||
var PATH_APP_NODE_MODULES = path.join(__dirname, '..', '..', 'app', 'node_modules'); | ||
require('module').globalPaths.push(PATH_APP_NODE_MODULES); | ||
} | ||
``` |