Skip to content

Commit 84ecffe

Browse files
committed
Add electron, webpack, vue example
1 parent 181bf76 commit 84ecffe

File tree

8 files changed

+108
-0
lines changed

8 files changed

+108
-0
lines changed

electron-webpack-vuejs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

electron-webpack-vuejs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Electron with webpack and Vue.js
2+
3+
> [https://youtu.be/oL7vIDkDOsg](https://youtu.be/oL7vIDkDOsg)
4+
5+
Install [Node.js](https://nodejs.org/).
6+
7+
Within this folder run the terminal command `npm install` to install the
8+
`dependencies` and `devDependencies`.
9+
10+
Then run `npm start` to run the app.

electron-webpack-vuejs/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "electron-webpack-vuejs",
3+
"version": "0.1.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "electron-webpack dev",
8+
"build": "electron-webpack && electron-builder"
9+
},
10+
"author": "Kyle Robinson Young <kyle@dontkry.com> (http://dontkry.com)",
11+
"license": "MIT",
12+
"devDependencies": {
13+
"electron": "^2.0.2",
14+
"electron-builder": "^20.15.1",
15+
"electron-webpack": "^2.1.2",
16+
"vue": "^2.5.16",
17+
"vue-loader": "^15.2.2",
18+
"vue-template-compiler": "^2.5.16",
19+
"webpack": "^4.9.1"
20+
},
21+
"dependencies": {
22+
"source-map-support": "^0.5.6"
23+
}
24+
}

electron-webpack-vuejs/src/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title><%= process.env.npm_package_productName %></title>
5+
<meta charset="utf-8">
6+
<script>
7+
<% if (htmlWebpackPlugin.options.nodeModules) { %>
8+
require('module').globalPaths.push(
9+
'<%= htmlWebpackPlugin.options.nodeModules %>'.replace(/\\/g, '\\\\'),
10+
)
11+
<% } %>
12+
require('source-map-support/source-map-support.js').install()
13+
</script>
14+
</head>
15+
<body>
16+
<div id="app"></div>
17+
</body>
18+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { app, BrowserWindow } from 'electron'
2+
import path from 'path'
3+
import { format as formatUrl } from 'url'
4+
5+
const isDevelopment = process.env.NODE_ENV !== 'production'
6+
7+
app.on('ready', () => {
8+
let window = new BrowserWindow({
9+
width: 1024
10+
})
11+
if (isDevelopment) {
12+
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
13+
} else {
14+
window.loadURL(formatUrl({
15+
pathname: path.join(__dirname, 'index.html'),
16+
protocol: 'file',
17+
slashes: true
18+
}))
19+
}
20+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div>{{name}}</div>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data() {
8+
return {
9+
name: 'Obligatory Bear'
10+
}
11+
}
12+
}
13+
</script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Vue from 'vue'
2+
import App from './App.vue'
3+
new Vue({
4+
el: '#app',
5+
render(h) {
6+
return h(App)
7+
}
8+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
2+
module.exports = {
3+
module: {
4+
rules: [
5+
{
6+
test: /\.vue$/,
7+
use: 'vue-loader'
8+
}
9+
]
10+
},
11+
plugins: [
12+
new VueLoaderPlugin()
13+
]
14+
}

0 commit comments

Comments
 (0)