Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
devops724 committed Mar 28, 2020
1 parent 7de49f3 commit 37e2380
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

node_modules
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# Electron-Vue-Webpack4-Simple-Boilerplate
most Simple vue Webpack Electron config

#setup
npm install

#run
open two terminal
in first
npm run dev
in second
npm start
6 changes: 6 additions & 0 deletions app/build/bundle.js

Large diffs are not rendered by default.

Binary file added app/build/electron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/build/vue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/build/webpack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Electron + Vue + Webpack</title>
</head>
<body>
<div id="app"></div>
<script src="build/bundle.js"></script>
</body>
</html>
85 changes: 85 additions & 0 deletions app/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<div id='app'>
<img class='logo' src='src/assets/electron.png' />
<img class='logo' src='src/assets/vue.png' />
<img class='logo' src='src/assets/webpack.png' />
<hello></hello>
<p>
If you are trying to build Electron apps using Vue 2, or you just
want to play around with them, feel free to use this
seed as starting point.
</p>
<p>
Pay attention to how resources inside src/ folder are built, CSS code
inside .vue components is embed into the HTML file when loaded, or
simply relative image paths are updated to public paths after
building with Webpack.
</p>
<p>
Here are the docs for
<a href='#' @click="link('http://electron.atom.io/docs/')">
Electron</a>,
<a href='#' @click="link('http://vuejs.org/guide/')">
Vue 2</a> and
<a href='#' @click="link('http://webpack.github.io/docs/')">
Webpack</a>.
Customize this template as you wish by adding any
fancy tool you are used to.
</p>
<p>
If you have any issues, please
file an issue at this seed's
<a href='#' @click="link('https://github.com/pastahito/electron-vue-webpack')">
repository</a>.
</p>
</div>
</template>

<script>
import Hello from './components/Hello.vue'
// With shell.openExternal(url) is how
// external urls must be handled, not href
const shell = require('electron').shell
export default {
components: {
Hello
},
methods: {
link: (url) => {
shell.openExternal(url)
}
}
}
</script>

<style>
html {
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
margin: auto;
}
#app {
color: #2c3e50;
max-width: 600px;
font-family: Source Sans Pro, Helvetica, sans-serif;
text-align: center;
}
#app a {
color: #42b983;
text-decoration: none;
}
#app p {
text-align: justify;
}
.logo {
width: auto;
height: 100px;
}
</style>
Binary file added app/src/assets/electron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/assets/vue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/assets/webpack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions app/src/components/Hello.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div class='hello'>
<h1>{{ msg }}</h1>
</div>
</template>

<script>
export default {
data () {
return {
msg: 'Hello Vue!'
}
}
}
</script>

<style scoped>
h1 {
color: #42b983;
}
</style>
7 changes: 7 additions & 0 deletions app/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Vue from 'vue'
import App from './App.vue'

new Vue({
el: '#app',
render: h => h(App)
})
20 changes: 20 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Basic init
const electron = require('electron')
const {app, BrowserWindow} = electron

// Let electron reloads by itself when webpack watches changes in ./app/
require('electron-reload')(__dirname)

// To avoid being garbage collected
let mainWindow

app.on('ready', () => {

let mainWindow = new BrowserWindow({width: 800, height: 600,
webPreferences: {
nodeIntegration: true
}})

mainWindow.loadFile(`app/index.html`)

})
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "electron-vue-webpack",
"version": "1.0.0",
"description": "A minimal Electron + Vue 2 + Webpack 2 setup with few dependencies for quick development.",
"main": "main.js",
"scripts": {
"dev": "webpack",
"start": "electron . --no-sandbox"
},
"author": "J. Renato Ramos González <[email protected]>",
"repository": {
"type": "git",
"url": "git+https://github.com/pastahito/electron-vue-webpack.git"
},
"license": "WTFPL",
"dependencies": {
"vue": "^2.0.1"
},
"devDependencies": {
"css-loader": "^3.4.2",
"electron": "^8.1.1",
"electron-reload": "^1.5.0",
"fibers": "^4.0.2",
"file-loader": "^6.0.0",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"vue-loader": "^15.9.1",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"bugs": {
"url": "https://github.com/pastahito/electron-vue-webpack/issues"
},
"homepage": "https://github.com/pastahito/electron-vue-webpack#readme"
}
80 changes: 80 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const { VueLoaderPlugin } = require('vue-loader')
module.exports = {

watch: true,
mode:"production",
target: 'electron-main',

entry: './app/src/entry.js',

output: {
path: __dirname + '/app/build',
publicPath: 'build/',
filename: 'bundle.js'
},

module: {
rules: [


{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},

{
test: /\.(svg|woff|woff2|ttf|eot|otf)([\?]?.*)$/,
loader: 'file-loader?name=assets/fonts/[name].[ext]',
},
{
test: /\.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
// Requires sass-loader@^8.0.0
options: {
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
indentedSyntax: true // optional
},
},
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
/*include: [
path.resolve(__dirname, 'node_modules'),
]*/

},
]
},

resolve: {
alias: {vue: 'vue/dist/vue.js'}
},
plugins: [
/*new HtmlWebpackPlugin({
template: "./src/index.html"
}),*/
new VueLoaderPlugin()
],

}

0 comments on commit 37e2380

Please sign in to comment.