Skip to content

Commit

Permalink
bug: 🐛 trying to fix server in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
DNature committed Oct 2, 2020
1 parent 375904e commit b099ddd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 31 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": "[email protected]"
}
}
}
37 changes: 16 additions & 21 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title>
</head>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<script>
const {
server
} = require('hardocs-graphql-api');
<body style="background-color: white;">
<div id="app"></div>
<script>
const { server } = require('hardocs-graphql-api');

server();
</script>
<title><%= htmlWebpackPlugin.options.title %></title>
</head>

<body style="background-color: white;">
<div id="app"></div>


</body>

</html>
//create a server object:
server();
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
}
});

Expand Down
12 changes: 12 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -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
18 changes: 12 additions & 6 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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'
}
}
}
}
};

0 comments on commit b099ddd

Please sign in to comment.