Simplify structure.

Now using electron-webpack.
Additional frameworks will be added down the line as this setup becomes
more comfortable.
This commit is contained in:
Daniel Scalzi 2020-04-13 05:56:26 -04:00
parent b9536ed014
commit 3cde9ef75e
No known key found for this signature in database
GPG Key ID: D18EA3FB4B142A57
13 changed files with 2191 additions and 1159 deletions

View File

@ -177,19 +177,6 @@ Note that you **cannot** open the DevTools window while using this debug configu
---
### Note on Third-Party Usage
You may use this software in your own project so long as the following conditions are met.
* Credit is expressly given to the original authors (Daniel Scalzi).
* Include a link to the original source on the launcher's About page.
* Credit the authors and provide a link to the original source in any publications or download pages.
* The source code remain **public** as a fork of this repository.
We reserve the right to update these conditions at any time, please check back periodically.
---
## Resources
* [Wiki][wiki]
@ -210,3 +197,5 @@ The best way to contact the developers is on Discord.
[chromedebugger]: https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome 'Debugger for Chrome'
[discord]: https://discord.gg/zNWUXdt 'Discord'
[wiki]: https://github.com/dscalzi/HeliosLauncher/wiki 'wiki'
© 2020 Daniel Scalzi All Rights Reserved

3054
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,15 +21,8 @@
"dist:mac": "npm run dist -- MAC",
"dist:linux": "npm run dist -- LINUX",
"lint": "eslint --ext=jsx,js,tsx,ts src",
"build-main": "cross-env NODE_ENV=production webpack --config webpack.main.prod.config.js",
"build-renderer": "cross-env NODE_ENV=production webpack --config webpack.renderer.prod.config.js",
"build": "npm run build-main && npm run build-renderer",
"start-renderer-dev": "webpack-dev-server --config webpack.renderer.dev.config.js",
"start-main-dev": "webpack --config webpack.main.config.js && electron ./dist/main.js",
"start-dev": "cross-env START_HOT=1 npm run start-renderer-dev",
"pack": "npm run build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true node build.js --dir",
"dist": "npm run build && cross-env ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true node build.js",
"postinstall": "electron-builder install-app-deps"
"dev": "electron-webpack dev",
"compile": "electron-webpack"
},
"engines": {
"node": "12.x.x"
@ -39,7 +32,7 @@
"async": "^3.2.0",
"discord-rpc": "3.1.0",
"electron-updater": "^4.2.4",
"fs-extra": "^8.1.0",
"fs-extra": "^9.0.0",
"github-syntax-dark": "^0.5.0",
"jquery": "^3.4.1",
"request": "^2.88.2",
@ -48,12 +41,7 @@
"winreg": "^1.2.4"
},
"devDependencies": {
"@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/polyfill": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@babel/preset-react": "^7.9.4",
"@types/adm-zip": "^0.4.32",
"@types/async": "^3.0.8",
"@types/discord-rpc": "^3.0.2",
@ -62,34 +50,22 @@
"@types/node": "^12.12.29",
"@types/react": "^16.9.23",
"@types/react-dom": "^16.9.5",
"@types/react-redux": "^7.1.7",
"@types/request": "^2.48.4",
"@types/tar-fs": "^1.16.2",
"@types/winreg": "^1.2.30",
"babel-loader": "^8.0.6",
"cross-env": "^7.0.2",
"css-loader": "^3.4.2",
"electron": "^7.1.14",
"electron": "^8.2.1",
"electron-builder": "^22.4.0",
"electron-devtools-installer": "^2.2.4",
"electron-webpack": "^2.8.2",
"electron-webpack-ts": "^4.0.1",
"eslint": "^6.8.0",
"fork-ts-checker-webpack-plugin": "^4.0.5",
"helios-distribution-types": "1.0.0-pre.1",
"html-webpack-plugin": "^3.2.0",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-hot-loader": "^4.12.19",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"rimraf": "^3.0.2",
"source-map-loader": "^0.2.4",
"style-loader": "^1.1.3",
"typescript": "^3.8.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-merge": "^4.2.2"
"webpack": "^4.42.0"
},
"repository": {
"type": "git",

View File

@ -1,5 +1,5 @@
import { EventEmitter } from 'events'
import request = require('request')
import request from 'request'
import { join } from 'path'
import { pathExistsSync, pathExists, readdir, exists, readFileSync, createWriteStream, ensureDirSync, readFile, writeFileSync, unlink, createReadStream, readJsonSync } from 'fs-extra'
import Registry from 'winreg'

View File

@ -118,11 +118,23 @@ async function createWindow() {
// ejse.data('bkid', Math.floor((Math.random() * readdirSync(join(__dirname, '..', 'assets', 'images', 'backgrounds')).length)))
if (isdev) {
win.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
}
else {
win.loadURL(format({
pathname: join(__dirname, 'index.html'),
protocol: 'file:',
protocol: 'file',
slashes: true
}))
}
// console.log(__dirname)
// win.loadURL(format({
// pathname: join(__dirname, 'index.html'),
// protocol: 'file',
// slashes: true
// }))
/*win.once('ready-to-show', () => {
win.show()

View File

@ -1,28 +1,30 @@
{
"compilerOptions": {
/* Basic Options */
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [ /* Specify library files to be included in the compilation. */
"DOM",
"ES2019"
],
"allowJs": true, /* Allow javascript files to be compiled. */
// *"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
// *"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// *"lib": [ /* Specify library files to be included in the compilation. */
// * "DOM",
// * "ES2019"
// *],
// *"allowJs": true, /* Allow javascript files to be compiled. */
"jsx": "react",
"noUnusedLocals": false,
// "checkJs": true, /* Report errors in .js files. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "dist", /* Redirect output structure to the directory. */
"strict": true,
// *"sourceMap": true, /* Generates corresponding '.map' file. */
// *"outDir": "dist", /* Redirect output structure to the directory. */
// *"strict": true,
// "baseUrl": ".", /* Base directory to resolve non-absolute module names. */
// "paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "*": ["node_modules/*"]
// },
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// *"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"include": [
"./src"
],
"exclude": [ "node_modules" ]
// *"include": [
// * "./src"
// *],
// *"exclude": [ "node_modules" ],
"extends": "./node_modules/electron-webpack/tsconfig-base.json"
}

View File

@ -1,21 +0,0 @@
'use strict'
const path = require('path')
module.exports = {
mode: 'development',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
node: {
__dirname: false,
__filename: false
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json']
},
devtool: 'source-map',
plugins: [
]
}

View File

@ -1,43 +0,0 @@
const webpack = require('webpack')
const merge = require('webpack-merge')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const baseConfig = require('./webpack.base.config')
module.exports = merge.smart(baseConfig, {
target: 'electron-main',
entry: {
main: './src/main/main.ts'
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
[
'@babel/preset-env',
{ targets: 'maintained node versions' }
],
'@babel/preset-typescript'
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }]
]
}
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin({
reportFiles: ['src/main/**/*']
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
]
})

View File

@ -1,7 +0,0 @@
const merge = require('webpack-merge')
const baseConfig = require('./webpack.main.config')
module.exports = merge.smart(baseConfig, {
mode: 'production'
})

View File

@ -1,73 +0,0 @@
const webpack = require('webpack')
const merge = require('webpack-merge')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const baseConfig = require('./webpack.base.config')
module.exports = merge.smart(baseConfig, {
target: 'electron-renderer',
entry: {
app: ['@babel/polyfill','./src/renderer/app.tsx']
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
[
'@babel/preset-env',
{ targets: { browsers: 'last 2 versions ' } }
],
'@babel/preset-typescript',
'@babel/preset-react'
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }]
]
}
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
disable: true
}
}
]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin({
reportFiles: ['src/renderer/**/*']
}),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
]
})

View File

@ -1,32 +0,0 @@
const merge = require('webpack-merge')
const spawn = require('child_process').spawn
const baseConfig = require('./webpack.renderer.config')
module.exports = merge.smart(baseConfig, {
devServer: {
port: 2003,
compress: true,
noInfo: true,
stats: 'errors-only',
inline: true,
hot: true,
headers: { 'Access-Control-Allow-Origin': '*' },
historyApiFallback: {
verbose: true,
disableDotRule: false
},
before() {
if (process.env.START_HOT) {
console.log('Starting main process')
spawn('npm', ['run', 'start-main-dev'], {
shell: true,
env: process.env,
stdio: 'inherit'
})
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError))
}
}
}
})

View File

@ -1,7 +0,0 @@
const merge = require('webpack-merge')
const baseConfig = require('./webpack.renderer.config')
module.exports = merge.smart(baseConfig, {
mode: 'production'
})