Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
305720a
commit 9316dba
Showing
10 changed files
with
7,306 additions
and
1 deletion.
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,5 @@ | ||
.DS_Store | ||
dist/ | ||
node_modules/ | ||
thumbs.db | ||
.idea/ |
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,39 @@ | ||
# test directories | ||
__tests__ | ||
node_modules/*/test | ||
node_modules/*/tests | ||
powered-test | ||
|
||
# asset directories | ||
docs | ||
doc | ||
website | ||
images | ||
|
||
# examples | ||
example | ||
examples | ||
|
||
# code coverage directories | ||
coverage | ||
.nyc_output | ||
|
||
# build scripts | ||
Makefile | ||
Gulpfile.js | ||
Gruntfile.js | ||
|
||
# configs | ||
.tern-project | ||
.gitattributes | ||
.editorconfig | ||
.*ignore | ||
.eslintrc | ||
.jshintrc | ||
.flowconfig | ||
.documentup.json | ||
.yarn-metadata.json | ||
|
||
# misc | ||
*.gz | ||
*.md |
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,29 @@ | ||
{ | ||
"name": "electron-webpack-quick-start", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "electron-webpack dev", | ||
"build": "electron-webpack", | ||
"dist": "yarn build && electron-builder", | ||
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null" | ||
}, | ||
"devDependencies": { | ||
"electron": "8.2.0", | ||
"electron-builder": "^22.4.1", | ||
"electron-webpack": "^2.8.2", | ||
"mini-css-extract-plugin": "^1.3.9", | ||
"sass": "^1.32.8", | ||
"sass-loader": "^10.1.0", | ||
"svelte": "^3.35.0", | ||
"svelte-loader-hot": "^0.3.1", | ||
"svelte-preprocess": "^4.6.9", | ||
"webpack": "~4.42.1" | ||
}, | ||
"electronWebpack": { | ||
"renderer": { | ||
"sourceDirectory": "src/renderer-svelte", | ||
"webpackConfig": "./webpack.svelte.renderer.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,64 @@ | ||
import { app, BrowserWindow, ipcMain } from 'electron'; | ||
import * as path from 'path'; | ||
import { format as formatUrl } from 'url'; | ||
|
||
const isDevelopment = process.env.NODE_ENV !== 'production'; | ||
|
||
// global reference to mainWindow (necessary to prevent window from being garbage collected) | ||
let mainWindow; | ||
|
||
function createMainWindow() { | ||
const window = new BrowserWindow({webPreferences: {nodeIntegration: true}}); | ||
|
||
if (isDevelopment) { | ||
window.webContents.openDevTools(); | ||
} | ||
|
||
if (isDevelopment) { | ||
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`); | ||
} | ||
else { | ||
window.loadURL(formatUrl({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file', | ||
slashes: true, | ||
})); | ||
} | ||
|
||
window.on('closed', () => { | ||
mainWindow = null; | ||
}); | ||
|
||
window.webContents.on('devtools-opened', () => { | ||
window.focus(); | ||
setImmediate(() => { | ||
window.focus(); | ||
}); | ||
}); | ||
|
||
return window; | ||
} | ||
|
||
// quit application when all windows are closed | ||
app.on('window-all-closed', () => { | ||
// on macOS it is common for applications to stay open until the user explicitly quits | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on('activate', () => { | ||
// on macOS it is common to re-create a window even after all windows have been closed | ||
if (mainWindow === null) { | ||
mainWindow = createMainWindow(); | ||
} | ||
}); | ||
|
||
// create main BrowserWindow when electron is ready | ||
app.on('ready', () => { | ||
mainWindow = createMainWindow(); | ||
|
||
ipcMain.on("test", ( e, data ) => { | ||
mainWindow?.webContents.send("cool", "cool cool", Date.now()); | ||
}); | ||
}); |
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,24 @@ | ||
<script> | ||
export let makeCall; | ||
export let name; | ||
import { fly } from 'svelte/transition'; | ||
import Header from "./Header.svelte"; | ||
$: count = 0; | ||
</script> | ||
|
||
<style type="text/scss"> | ||
div { | ||
color: red; | ||
} | ||
</style> | ||
|
||
<Header/> | ||
<div>Hello {name}!</div> | ||
<button on:click={() => {makeCall();count++;}} color="primary">click</button> | ||
<p>COOL {count}</p> | ||
{#if count % 2} | ||
<div transition:fly="{{delay: 250, duration: 300, x:10, y: 10}}"> | ||
fades in and out | ||
</div> | ||
{/if} |
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 @@ | ||
<div>HEADER</div> |
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,17 @@ | ||
import { ipcRenderer } from "electron"; | ||
import App from "./App.svelte"; | ||
|
||
const makeCall = () => { | ||
console.log("making call"); | ||
ipcRenderer.send("test", "hello"); | ||
} | ||
|
||
ipcRenderer.on("cool", console.log); | ||
|
||
new App({ | ||
target: document.body, | ||
props: { | ||
name: 'World', | ||
makeCall | ||
} | ||
}); |
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,50 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
const sveltePreprocess = require('svelte-preprocess'); | ||
|
||
const IS_DEV = process.env.NODE_ENV !== 'production'; | ||
|
||
console.log({IS_DEV}); | ||
|
||
const config = { | ||
resolve: { | ||
alias: { | ||
svelte: path.dirname(require.resolve('svelte/package.json')), | ||
}, | ||
extensions: ['.mjs', '.js', '.svelte'], | ||
mainFields: ['svelte', 'browser', 'module', 'main'], | ||
}, | ||
devServer: { | ||
hot: true, | ||
}, | ||
devtool: IS_DEV ? 'source-map' : false, | ||
module: { | ||
rules: [ | ||
{ test: /\.svelte$/, use: { | ||
loader: 'svelte-loader-hot', | ||
options: { | ||
dev: IS_DEV, | ||
preprocess: sveltePreprocess(), | ||
emitCss: !IS_DEV, | ||
hotReload: IS_DEV | ||
}, | ||
}}, | ||
{ test: /\.(sa|sc|c)ss$/, use: [(IS_DEV?'style-loader':MiniCssExtractPlugin.loader), 'css-loader', 'sass-loader'] }, | ||
{ test: /\.eot(\?v=.*)?$/, use: ['file-loader'] }, | ||
{ test: /\.(ico|png|gif|jpe?g)$/i, use: ['file-loader'] }, | ||
{ test: /\.woff2?(\?v=.*)?$/, use: [{ loader: 'url-loader', options: { prefix: 'font/', limit: 5000 } }] }, | ||
{ test: /\.ttf(\?v=.*)?$/, use: [{ loader: 'url-loader', options: { mimetype: 'application/octet-stream', limit: 10000 } }] }, | ||
{ test: /\.svg(\?v=.*)?$/, use: [{ loader: 'url-loader', options: { mimetype: 'image/svg+xml', limit: 10000 } }] }, | ||
// { test: /node_modules\/svelte\/.*\.mjs$/, resolve: {fullySpecified: false}}, | ||
], | ||
}, | ||
plugins: [], | ||
}; | ||
|
||
if (IS_DEV) { | ||
// config.plugins.push(new webpack.HotModuleReplacementPlugin()); | ||
} else { | ||
config.plugins.push(new MiniCssExtractPlugin()); | ||
} | ||
module.exports = config; |
Oops, something went wrong.