🎉 Initial commit

This commit is contained in:
Tiana Lemesle 2021-02-22 13:30:43 +01:00
commit 2dc8238924
11 changed files with 6245 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
dist
build
.cache
.idea

9
App.vue Normal file
View File

@ -0,0 +1,9 @@
<template>
<div id="app">
<p>Hello</p>
</div>
</template>
<script>
export default {}
</script>

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# template-vue-parcel
[Electron](https://github.com/electron/electron) v11.x + [Vue.JS](https://github.com/vuejs/vue) v2.x + [Parcel Bundler](https://github.com/parcel-bundler/parcel) v1.x template

40
build.js Normal file
View File

@ -0,0 +1,40 @@
const
fs = require('fs'),
Parcel = require('parcel-bundler'),
electronPackager = require('electron-packager'),
{
icon,
build: {
ignoredDirectories,
platforms
}
} = require('./config.json');
const options = {
icon,
dir: __dirname,
arch: 'x64',
ignore: [
'.gitignore',
'build.js',
'README.md',
'yarn.lock',
...ignoredDirectories,
...fs.readFileSync('./.gitignore', 'utf8')
.split('\n')
.filter(path => path !== 'dist')
],
out: 'build',
asar: true,
overwrite: true
};
(async () => {
fs.rmdirSync('./dist', { recursive: true });
await new Parcel('index.html', { publicURL: '.' }).bundle();
await Promise.all(platforms.map(platform => electronPackager({
...options,
platform
})));
process.exit();
})();

10
config.json Normal file
View File

@ -0,0 +1,10 @@
{
"port": 5492,
"icon": "",
"enableTitleBar": false,
"enableMenuBar": false,
"build": {
"ignoredDirectories": ["docs"],
"platforms": ["linux"]
}
}

11
index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>vue-parcel</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
<script defer src="./main.js"></script>
<body>
<div id="app"></div>
</body>
</html>

32
index.js Normal file
View File

@ -0,0 +1,32 @@
const
{ app, BrowserWindow } = require('electron'),
path = require('path'),
Parcel = app.isPackaged ? undefined : require('parcel-bundler'),
{
port,
icon,
enableTitleBar,
enableMenuBar
} = require('./config.json');
app.once('ready', async () => {
const mainWindow = new BrowserWindow({
...enableTitleBar === false ? {
frame: false
} : {},
icon,
webPreferences: {
preload: path.join(__dirname, './preload.js'),
contextIsolation: true
},
show: false
});
if(enableMenuBar === false) mainWindow.setMenuBarVisibility(false);
if(app.isPackaged) await mainWindow.loadFile('./dist/index.html');
else {
mainWindow.openDevTools();
await new Parcel(path.join(__dirname, './index.html')).serve(port);
await mainWindow.loadURL(`http://localhost:${port}/`);
}
mainWindow.show();
});

8
main.js Normal file
View File

@ -0,0 +1,8 @@
import Vue from 'vue';
import App from './App.vue';
new Vue({
el: '#app',
render: h => h(App)
});

26
package.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "electron-vue-parcel",
"version": "0.1.0",
"scripts": {
"start": "./node_modules/.bin/electron index.js",
"build": "node ./build.js"
},
"dependencies": {
"electron": "^11.3.0",
"electron-packager": "^15.2.0",
"parcel-bundler": "^1.12.4",
"vue": "^2.6.11",
"vue-hot-reload-api": "^2.3.4"
},
"devDependencies": {
"@vue/component-compiler-utils": "^3.1.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"since 2017-06"
],
"engines": {
"node": ">=12"
},
"engineStrict": true
}

1
preload.js Normal file
View File

@ -0,0 +1 @@
console.log('Hello');

6100
yarn.lock Normal file

File diff suppressed because it is too large Load Diff