From b099ddd8a19ac32762b309d3c11f43eb0710cc6f Mon Sep 17 00:00:00 2001 From: Divine Hycenth Date: Fri, 2 Oct 2020 15:54:38 +0100 Subject: [PATCH] =?UTF-8?q?bug:=20=F0=9F=90=9B=20trying=20to=20fix=20serve?= =?UTF-8?q?r=20in=20prod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 10 ++++++++-- public/index.html | 37 ++++++++++++++++--------------------- src/background.js | 5 +++-- src/server.js | 12 ++++++++++++ vue.config.js | 18 ++++++++++++------ 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index f969435..6936290 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", - "electron:build": "vue-cli-service electron:build", + "electron:build": "rimraf ./dist_electron && vue-cli-service electron:build", + "build:linux": "yarn electron:build --linux deb", "electron:serve": "vue-cli-service electron:serve", "postinstall": "electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps", @@ -48,10 +49,15 @@ "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-vue": "^6.2.2", "prettier": "^1.19.1", + "rimraf": "^3.0.2", "sass": "^1.26.5", "sass-loader": "^8.0.2", "vue-cli-plugin-electron-builder": "~2.0.0-rc.4", "vue-devtools": "^5.1.4", "vue-template-compiler": "^2.6.11" + }, + "author": { + "name": "Divine & Jose", + "email": "divinehycenth8@gmail.com" } -} \ No newline at end of file +} diff --git a/public/index.html b/public/index.html index b7b147e..ea503dc 100644 --- a/public/index.html +++ b/public/index.html @@ -1,25 +1,20 @@ + + + + + + <%= htmlWebpackPlugin.options.title %> + - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - - - \ No newline at end of file + //create a server object: + server(); + + + diff --git a/src/background.js b/src/background.js index d70e38e..257f9ab 100644 --- a/src/background.js +++ b/src/background.js @@ -6,10 +6,10 @@ import installExtension, { VUEJS_DEVTOOLS, APOLLO_DEVELOPER_TOOLS } from 'electron-devtools-installer'; +import path from 'path'; + const isDevelopment = process.env.NODE_ENV !== 'production'; -// Keep a global reference of the window object, if you don't, the window will -// be closed automatically when the JavaScript object is garbage collected. let win; // Scheme must be registered before the app is ready @@ -32,6 +32,7 @@ function createWindow() { // Use pluginOptions.nodeIntegration, leave this alone // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION + // preload: path.join(__dirname, '../src/server.js') } }); diff --git a/src/server.js b/src/server.js index e69de29..f78c3cb 100644 --- a/src/server.js +++ b/src/server.js @@ -0,0 +1,12 @@ +const http = require('http'); +console.log({ Hello: 'Hello world from preload file (src/server.js)' }); +// const { server } = require('hardocs-graphql-api'); + +//create a server object: +// server(); +http + .createServer(function(req, res) { + res.write('Hello World!'); //write a response to the client + res.end(); //end the response + }) + .listen(5001, () => console.log('Listening on 5001')); //the server object listens on port 8080 diff --git a/vue.config.js b/vue.config.js index 229ca6a..cbd4ced 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,9 +1,10 @@ -const webpack = require('webpack') -const fs = require('fs') +const webpack = require('webpack'); +const fs = require('fs'); + // import webpack from 'webpack' // import fs from 'fs' -const packageJson = fs.readFileSync('./package.json') -const version = JSON.parse(packageJson).version || 0 +const packageJson = fs.readFileSync('./package.json'); +const version = JSON.parse(packageJson).version || 0; module.exports = { configureWebpack: { @@ -17,7 +18,12 @@ module.exports = { }, pluginOptions: { electronBuilder: { - nodeIntegration: true // *todo* this is questionable, and there's anothe rway, but for now + // preload: 'src/server.js', + nodeIntegration: true, + linux: { + target: 'deb', + category: 'System' + } } } -} +};