forked from saltyshiomix/nextron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new example (remote-require) :)
- Loading branch information
1 parent
8107b0a
commit bf41d02
Showing
9 changed files
with
162 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
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,31 @@ | ||
<p align="center"><img src="https://i.imgur.com/9fdMREj.png"></p> | ||
|
||
## Usage | ||
|
||
### Create an App | ||
|
||
```bash | ||
# with `nextron` | ||
$ nextron init my-app --example remote-require | ||
|
||
# with npx | ||
$ npx create-nextron-app my-app --example remote-require | ||
|
||
# with yarn | ||
$ yarn create nextron-app my-app --example remote-require | ||
``` | ||
|
||
### Use it | ||
|
||
```bash | ||
$ cd my-app | ||
|
||
# Install dependencies | ||
$ yarn (or `npm install`) | ||
|
||
# Run development mode | ||
$ yarn dev (or `npm run dev`) | ||
|
||
# Build packages | ||
$ yarn build (or `npm run build`) | ||
``` |
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,12 @@ | ||
appId: com.example.nextron | ||
productName: My Nextron App | ||
copyright: Copyright © 2018 Yoshihide Shiono | ||
directories: | ||
output: dist | ||
buildResources: resources | ||
files: | ||
- from: . | ||
filter: | ||
- package.json | ||
- app | ||
publish: null |
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,5 @@ | ||
const config = { | ||
message: 'This message is from the main process of `config.js`', | ||
}; | ||
|
||
export default config; |
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,8 @@ | ||
module.exports = { | ||
webpack: (defaultConfig, env) => Object.assign(defaultConfig, { | ||
entry: { | ||
background: './main/background.js', | ||
config: './main/config.js', | ||
}, | ||
}), | ||
}; |
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,25 @@ | ||
{ | ||
"private": true, | ||
"name": "my-nextron-app", | ||
"description": "My application description", | ||
"version": "1.0.0", | ||
"author": "Yoshihide Shiono <shiono.yoshihide@gmail.com>", | ||
"main": "app/background.js", | ||
"scripts": { | ||
"dev": "nextron", | ||
"build": "nextron build", | ||
"postinstall": "electron-builder install-app-deps" | ||
}, | ||
"dependencies": { | ||
"electron-serve": "^0.3.0", | ||
"electron-store": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"electron": "^6.0.7", | ||
"electron-builder": "^21.2.0", | ||
"next": "^9.0.5", | ||
"nextron": "^5.9.2", | ||
"react": "^16.9.0", | ||
"react-dom": "^16.9.0" | ||
} | ||
} |
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,5 @@ | ||
module.exports = { | ||
webpack: (config) => Object.assign(config, { | ||
target: 'electron-renderer', | ||
}), | ||
}; |
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,40 @@ | ||
import electron from 'electron'; | ||
import React, { useState, useEffect } from 'react'; | ||
import Head from 'next/head'; | ||
import Link from 'next/link'; | ||
|
||
// prevent SSR webpacking | ||
const remote = electron.remote || false; | ||
|
||
const Home = () => { | ||
const [config, setConfig] = useState({}); | ||
|
||
useEffect(() => { | ||
// componentDidMount() | ||
if (remote) { | ||
setConfig(remote.require('./config').default); | ||
} | ||
|
||
return () => { | ||
// componentWillUnmount() | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Head> | ||
<title>Home - Nextron (remote-require)</title> | ||
</Head> | ||
<p> | ||
⚡ Electron + Next.js ⚡ - | ||
<Link href="/next"> | ||
<a>Go to next page</a> | ||
</Link> | ||
</p> | ||
<hr/> | ||
<p>{config.message}</p> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default Home; |
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,21 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import Link from 'next/link'; | ||
|
||
const Next = () => { | ||
return ( | ||
<React.Fragment> | ||
<Head> | ||
<title>Next - Nextron (remote-require)</title> | ||
</Head> | ||
<p> | ||
⚡ Electron + Next.js ⚡ - | ||
<Link href="/home"> | ||
<a>Go to home page</a> | ||
</Link> | ||
</p> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default Next; |