-
Notifications
You must be signed in to change notification settings - Fork 3
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
ebf64f9
commit ab1f8de
Showing
14 changed files
with
301 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/*.js | ||
config/*.js | ||
dist/*.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,17 @@ | ||
module.exports = { | ||
root: true, | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style | ||
extends: 'standard', | ||
// add your custom rules here | ||
'rules': { | ||
// allow paren-less arrow functions | ||
'arrow-parens': 0, | ||
'one-var': 0, | ||
// allow debugger during development | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, | ||
'brace-style': [2, 'stroustrup', { 'allowSingleLine': true }] | ||
} | ||
} |
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 | ||
node_modules/ | ||
dist/ | ||
npm-debug.log | ||
npm-debug.log.* |
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,40 @@ | ||
process.env.NODE_ENV = 'production' | ||
|
||
if (process.argv.length > 2) { | ||
process.env.PLATFORM_TARGET = process.argv[2] | ||
} | ||
|
||
require('colors') | ||
|
||
var | ||
packager = require('electron-packager'), | ||
shell = require('shelljs'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
config = require('../config/electron'), | ||
targetPath = path.join(__dirname, '../../dist'), | ||
webpackBuild = require('./webpack.builder.js') | ||
|
||
if (!fs.existsSync(targetPath)) { | ||
console.error('Please build your App before packaging for Electron...'.red) | ||
console.error('Issue "quasar build"'.red + ' from the root folder of your project'.gray + ' to make the build then try again.'.red) | ||
process.exit(1) | ||
} | ||
|
||
webpackBuild(function () { | ||
shell.cp(path.join(__dirname, '../dist/electron.js'), targetPath) | ||
shell.cp(path.join(__dirname, '../package.json'), targetPath) | ||
|
||
console.log(' Building Quasar Electron app(s)...\n'.bold) | ||
packager(config, (err, appPaths) => { | ||
if (err) { | ||
console.error('Error from `electron-packager` when building app...'.red) | ||
console.error(err) | ||
return | ||
} | ||
|
||
console.log(' Build(s) were successful.') | ||
console.log(appPaths) | ||
console.log('\n Done!'.bold + ' Check ' + path.resolve(__dirname, '../dist').gray + ' folder.') | ||
}) | ||
}) |
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,6 @@ | ||
var | ||
shell = require('shelljs'), | ||
path = require('path') | ||
|
||
shell.rm('-rf', path.resolve(__dirname, '../dist')) | ||
console.log(' Cleaned Electron build artifacts.\n') |
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,28 @@ | ||
var | ||
webpackConfig = require('./webpack.conf'), | ||
webpack = require('webpack') | ||
|
||
module.exports = function (done) { | ||
console.log((' Building Electron entry main.js...\n').bold) | ||
|
||
webpack(webpackConfig, function (err, stats) { | ||
if (err || (stats.compilation.errors && stats.compilation.errors.length)) { | ||
console.log(stats.compilation.errors.toString({ | ||
colors: true | ||
})) | ||
return | ||
} | ||
|
||
console.log(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n') | ||
|
||
console.log('\n Build complete for Electron main.js into dist/electron.js\n') | ||
|
||
done && done() | ||
}) | ||
} |
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,90 @@ | ||
var | ||
path = require('path'), | ||
webpack = require('webpack'), | ||
config = require('../config/webpack'), | ||
merge = require('webpack-merge'), | ||
ProgressBarPlugin = require('progress-bar-webpack-plugin') | ||
|
||
function resolve (dir) { | ||
return path.join(__dirname, '..', dir) | ||
} | ||
|
||
var folders = { | ||
src: resolve('src'), | ||
node_modules: resolve('node_modules'), | ||
dist: resolve('dist') | ||
} | ||
|
||
module.exports = { | ||
entry: { | ||
app: './src/main.js' | ||
}, | ||
target: 'node', | ||
externals: config.externals, | ||
output: { | ||
filename: 'electron.js', | ||
libraryTarget: 'commonjs2', | ||
path: folders.dist | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.json', '.node'], | ||
modules: [ | ||
folders.src, | ||
folders.node_modules | ||
] | ||
}, | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
module: { | ||
rules: [ | ||
{ // eslint | ||
enforce: 'pre', | ||
test: /\.js$/, | ||
loader: 'eslint-loader', | ||
include: folders.src, | ||
exclude: /node_modules/, | ||
options: { | ||
formatter: require('eslint-friendly-formatter') | ||
} | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
include: folders.src, | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.json$/, | ||
loader: 'json-loader' | ||
}, | ||
{ | ||
test: /\.node$/, | ||
loader: 'node-loader' | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': config.env | ||
}), | ||
new webpack.LoaderOptionsPlugin({ | ||
minimize: true | ||
}), | ||
// Progress Bar Webpack plugin format | ||
// https://github.com/clessg/progress-bar-webpack-plugin#options | ||
new ProgressBarPlugin({ | ||
format: ' [:bar] ' + ':percent'.bold + ' (:msg)' | ||
}), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
minimize: true, | ||
compress: { | ||
warnings: false | ||
} | ||
}) | ||
], | ||
performance: { | ||
hints: false | ||
} | ||
} |
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,3 @@ | ||
module.exports = { | ||
NODE_ENV: '"production"' | ||
} |
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,18 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
// electron-packager options | ||
// Docs: https://simulatedgreg.gitbooks.io/electron-vue/content/docs/building_your_app.html | ||
name: 'EPFLDojoApp', | ||
|
||
// Electron version | ||
electronVersion: require('../node_modules/electron/package.json').version, | ||
arch: 'x64', | ||
asar: true, | ||
dir: path.join(__dirname, '../../dist'), | ||
icon: path.join(__dirname, '../icons/icon'), | ||
ignore: /\b(node_modules|src|icons)\b/, | ||
out: path.join(__dirname, '../dist'), | ||
overwrite: true, | ||
platform: process.env.PLATFORM_TARGET || 'all' | ||
} |
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,8 @@ | ||
module.exports = { | ||
externals: { | ||
electron: 'electron', | ||
path: 'path' | ||
}, | ||
|
||
env: require('./build.env') | ||
} |
Binary file not shown.
Binary file not shown.
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,30 @@ | ||
{ | ||
"name": "EPFLDojoApp", | ||
"version": "0.0.1", | ||
"author": "EPFL-Dojo", | ||
"description": "EPFL Dojo app", | ||
"main": "electron.js", | ||
"scripts": { | ||
"dev": "cross-env NODE_ENV=development electron src/main.js", | ||
"clean": "node build/script.clean.js", | ||
"build": "node build/script.build.js" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.23.1", | ||
"babel-loader": "^6.3.2", | ||
"colors": "^1.1.2", | ||
"cross-env": "~3.1.4", | ||
"devtron": "^1.4.0", | ||
"electron": "^1.5.0", | ||
"electron-devtools-installer": "^2.0.1", | ||
"electron-packager": "^8.2.0", | ||
"eslint": "^3.16.0", | ||
"eslint-friendly-formatter": "^2.0.7", | ||
"eslint-loader": "^1.6.2", | ||
"json-loader": "^0.5.4", | ||
"node-loader": "^0.6.0", | ||
"shelljs": "^0.7.5", | ||
"webpack": "^2.2.1", | ||
"webpack-merge": "^3.0.0" | ||
} | ||
} |
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,53 @@ | ||
'use strict' | ||
|
||
const | ||
electron = require('electron'), | ||
path = require('path'), | ||
app = electron.app, | ||
BrowserWindow = electron.BrowserWindow | ||
|
||
let mainWindow | ||
|
||
function createWindow () { | ||
/** | ||
* Initial window options | ||
*/ | ||
mainWindow = new BrowserWindow({ | ||
height: 600, | ||
width: 800 | ||
}) | ||
|
||
mainWindow.loadURL( | ||
process.env.NODE_ENV === 'production' | ||
? `file://${__dirname}/index.html` | ||
: `http://localhost:${process.env.PORT || require('../../config').dev.port}` | ||
) | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
BrowserWindow.addDevToolsExtension(path.join(__dirname, '../node_modules/devtron')) | ||
|
||
let installExtension = require('electron-devtools-installer') | ||
|
||
installExtension.default(installExtension.VUEJS_DEVTOOLS) | ||
.then(name => mainWindow.webContents.openDevTools()) | ||
.catch(err => console.log('An error occurred: ', err)) | ||
} | ||
|
||
mainWindow.on('closed', () => { | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
app.on('ready', createWindow) | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) |