Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit f7ef1fb

Browse files
authored
Merge pull request #119 from skellock/homepage
✨ Makes home page link configurable.
2 parents 2ed3f09 + f77b5c8 commit f7ef1fb

File tree

10 files changed

+46
-19
lines changed

10 files changed

+46
-19
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"printWidth": 100,
33
"semi": false,
4-
"trailingComma": "es5"
4+
"trailingComma": "all"
55
}

docs/using.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Want to try this out? Clone & run. There's a small sample project included.
55
```sh
66
git clone --depth 1 git@github.com:skellock/typescript-with-electron-react-kit.git
77
cd typescript-with-electron-react-kit
8+
rm -rf .git
9+
git init
10+
git add .
811
npm i
912
npm start
1013
```
@@ -34,13 +37,10 @@ Open `package.json` and change these keys to be your own:
3437
* license
3538
* author
3639
* repository
40+
* homepage
3741
* build.mac.category
3842
* build.publish
3943

40-
#### Change Web Site Menu Item
41-
42-
Open `src/menu/shared-menu.ts` and change the visit menu item to point to your web site.
43-
4444
## Strip It Down to the Bones
4545

4646
If you're looking for a really fresh start:

fuse.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { FuseBox, CSSPlugin, Sparky, CopyPlugin } from "fuse-box"
1+
import { FuseBox, CSSPlugin, Sparky, CopyPlugin, ReplacePlugin } from "fuse-box"
22
import { spawn } from "child_process"
3+
import * as pjson from "./package.json"
34

45
const DEV_PORT = 4445
56
const OUTPUT_DIR = "out"
@@ -32,7 +33,16 @@ Sparky.task("default", ["copy-html"], () => {
3233
}
3334

3435
// bundle the electron main code
35-
const mainBundle = fuse.bundle("main").instructions("> [app/main.ts]")
36+
const mainBundle = fuse
37+
.bundle("main")
38+
.target("server")
39+
.instructions("> [app/main.ts]")
40+
// inject in some configuration
41+
.plugin(
42+
ReplacePlugin({
43+
"process.env.HOMEPAGE": pjson.homepage ? `"${pjson.homepage}"` : "null",
44+
}),
45+
)
3646

3747
// and watch unless we're bundling for production
3848
if (!isProduction) {

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
"email": "steve@kellock.ca",
1111
"name": "Steve Kellock"
1212
},
13-
"repository": "skellock/typescript-with-electron-react-kit",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/skellock/typescript-with-electron-react-kit.git"
16+
},
17+
"homepage": "https://github.com/skellock/typescript-with-electron-react-kit",
1418
"build": {
1519
"appId": "com.example.typescript-with-electron-react-kit",
1620
"files": [

src/menu/linux-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function createLinuxMenu(
2424

2525
const helpMenu: Electron.MenuItemConstructorOptions = {
2626
label: "Help",
27-
submenu: [shared.visit],
27+
submenu: [process.env.HOMEPAGE && shared.visit].filter(Boolean),
2828
}
2929

3030
return [fileMenu, viewMenu, helpMenu]

src/menu/macos-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function createMacMenu(
3434

3535
const helpMenu: Electron.MenuItemConstructorOptions = {
3636
label: "Help",
37-
submenu: [shared.visit],
37+
submenu: [process.env.HOMEPAGE && shared.visit].filter(Boolean),
3838
}
3939

4040
return [appMenu, viewMenu, helpMenu]

src/menu/shared-menu.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ export function createSharedMenuItems(window: Electron.BrowserWindow) {
44
const visit: Electron.MenuItemConstructorOptions = {
55
label: "On The Web",
66
click() {
7-
shell.openExternal("https://github.com/skellock/typescript-with-electron-react-kit")
7+
if (process.env.HOMEPAGE) {
8+
shell.openExternal(process.env.HOMEPAGE)
9+
}
810
},
911
}
1012

src/menu/windows-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function createWindowsMenu(
2424

2525
const helpMenu: Electron.MenuItemConstructorOptions = {
2626
label: "Help",
27-
submenu: [shared.visit],
27+
submenu: [process.env.HOMEPAGE && shared.visit].filter(Boolean),
2828
}
2929

3030
return [fileMenu, viewMenu, helpMenu]

typings/also-modules.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Tell the TS compiler that it's ok to load these
2+
// types of extensions. Fuse Box and Webpack will have
3+
// loaders that deal with these.
4+
//
5+
// You import like this:
6+
//
7+
// import * as thing from "image.jpg"
8+
//
9+
// Note these commands tell TypeScript that it's ok. This doesn't
10+
// automatically mean that you *can* import them. Ensure you've
11+
// got the proper plugins loaded in the `fuse.ts` configuration.
12+
13+
declare module "*.jpeg"
14+
declare module "*.jpg"
15+
declare module "*.gif"
16+
declare module "*.png"
17+
declare module "*.svg"
18+
declare module "*.json"

typings/images.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)